Web::Transport::AWS
Protocol features for Amazon Web Services (AWS) Web APIs
SYNOPSIS
use Web::Transport::AWS;
$form = Web::Transport::AWS->aws4_post_policy
(clock => Web::DateTime::Clock->realtime_clock,
max_age => 60*60,
access_key_id => $id,
secret_access_key => $key,
region => $region,
service => 's3',
policy_conditions => [
{"bucket" => $bucket},
...,
]);
## Then, generate a form using $form:
## <form metod=post
## action="https://$service-$region.amazonaws.com/$bucket/">
## <input type=hidden name=... value=...> created from $form
## ...
## <input type=hidden name="Content-Type" value="image/jpeg">
## ...
## </form>
DESCRIPTION
The Web::Transport::AWS
module implements protocol features for Amazon Web Services (AWS) Web APIs.
METHOD
The following method is available:
$new_url = Web::Transport::AWS->aws4_signed_url (...)
-
Sign a URL (create a pre-signed URL). It returns a new Web::URL object whose query contains the signature.
The arguments are name/value pairs of following options:
- url => $url (required)
-
The URL (a Web::URL object). It must be an HTTP(S) URL (i.e. a URL whose scheme is
http
orhttps
). - signed_hostport => $string
-
The hostport of the URL used to generate the signature. This option is required only when it is different from
url
's hostport. - method => $method (required)
-
The request method, such as
GET
orPOST
. - clock => $clock (required)
-
The clock used to generate the current timestamps (e.g.
Web::DateTime::Clock->realtime_clock
). - max_age => $seconds (required)
-
The lifetime of the signed URL, in seconds from the generation.
- access_key_id => $string (required)
-
The access key ID of the AWS credentials.
- secret_access_key => $string (required)
-
The secret access key of the AWS credentials.
- security_token => $string
-
The security token, as used in |X-Amz-Security-Token| parameter, if necessary.
- region => $string (required)
-
The AWS region identifier.
- service => $string (required)
-
The AWS service name, such as
s3
.
$form = Web::Transport::AWS->aws4_post_policy (...)
-
Prepare form data including POST policy JSON and its signature.
It returns a hash reference of form data name/value pairs, which should be used as basis of construction of form data submitted to the AWS S3 end points.
The arguments are name/value pairs of following options:
- clock => $clock (required)
-
The clock used to generate the current timestamps (e.g.
Web::DateTime::Clock->realtime_clock
). - max_age => $seconds (required)
-
The lifetime of the POST policy, in seconds from the generation.
- access_key_id => $string (required)
-
The access key ID of the AWS credentials.
- secret_access_key => $string (required)
-
The secret access key of the AWS credentials.
- security_token => $string
-
The security token, as used in |X-Amz-Security-Token| header, if necessary.
- region => $string (required)
-
The AWS region identifier.
- service => $string (required)
-
The AWS service name, such as
s3
. - policy_conditions => [$condition, ...] (required)
-
An array refeference of the conditions in the POST policy.
SEE ALSO
Signature Calculations for the Authorization Header: Transferring Payload in a Single Chunk (AWS Signature Version 4) - Amazon Simple Storage Service <https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html>
.
Creating a POST Policy - Amazon Simple Storage Service <https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-HTTPPOSTConstructPolicy.html>
.
Examples: Browser-Based Upload using HTTP POST (Using AWS Signature Version 4) - Amazon Simple Storage Service <https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-post-example.html>
.
AUTHOR
Wakaba <wakaba@suikawiki.org>.
LICENSE
Copyright 2017-2018 Wakaba <wakaba@suikawiki.org>.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.