Amazon-S3
view release on metacpan or search on metacpan
See [Amazon::S3::BucketV2](https://metacpan.org/pod/Amazon%3A%3AS3%3A%3ABucketV2) for more details.
- Limited Support for Directory Buckets
This version include limited support for directory buckets.
You can create and list directory buckets.
_Directory buckets use the S3 Express One Zone storage class, which
is recommended if your application is performance sensitive and
benefits from single-digit millisecond PUT and GET latencies._ -
[https://docs.aws.amazon.com/AmazonS3/latest/userguide/directory-buckets-overview.html](https://docs.aws.amazon.com/AmazonS3/latest/userguide/directory-buckets-overview.html)
- list\_directory\_buckets
List the directory buckets. Note this only returns a list of you
directory buckets, not their contents. In order to list the contents
of a directory bucket you must first create a session that establishes
temporary credentials used to acces the Zonal endpoints. You then use
those credentials for signing requests using the ListObjectV2 API.
lib/Amazon/S3.pm view on Meta::CPAN
########################################################################
sub turn_on_special_retry {
########################################################################
my ($self) = @_;
return
if !$self->retry;
# In the field we are seeing issue of Amazon returning with a 400
# code in the case of timeout. From AWS S3 logs: REST.PUT.PART
# Backups/2017-05-04/<account>.tar.gz "PUT
# /Backups<path>?partNumber=27&uploadId=<id> - HTTP/1.1" 400
# RequestTimeout 360 20971520 20478 - "-" "libwww-perl/6.15"
my $http_codes_hr = $self->ua->codes_to_determinate();
$http_codes_hr->{$HTTP_BAD_REQUEST} = $TRUE;
return;
}
########################################################################
sub turn_off_special_retry {
########################################################################
my ($self) = @_;
return
if !$self->retry;
# In the field we are seeing issue with Amazon returning a 400
# code in the case of timeout. From AWS S3 logs: REST.PUT.PART
# Backups/2017-05-04/<account>.tar.gz "PUT
# /Backups<path>?partNumber=27&uploadId=<id> - HTTP/1.1" 400
# RequestTimeout 360 20971520 20478 - "-" "libwww-perl/6.15"
my $http_codes_hr = $self->ua->codes_to_determinate();
delete $http_codes_hr->{$HTTP_BAD_REQUEST};
return;
}
########################################################################
sub region {
lib/Amazon/S3.pm view on Meta::CPAN
$self->dns_bucket_names(0);
my $data
= ( $region || $availability_zone )
? create_xml_request($request)
: $EMPTY;
$headers->{'Content-Length'} = length $data;
my $retval = $self->_send_request_expect_nothing(
{ method => 'PUT',
path => "$bucket/",
headers => $headers,
data => $data,
region => $region,
},
);
my $bucket_obj = $retval ? $self->bucket($bucket) : undef;
return $bucket_obj;
lib/Amazon/S3.pm view on Meta::CPAN
if $response->code =~ /^2\d\d$/xsm;
# anything else is a failure, and we save the parsed result
$self->_remember_errors( $response->content, $TRUE );
return $FALSE;
}
# Send a HEAD request first, to find out if we'll be hit with a 307 redirect.
# Since currently LWP does not have true support for 100 Continue, it simply
# slams the PUT body into the socket without waiting for any possible redirect.
# Thus when we're reading from a filehandle, when LWP goes to reissue the request
# having followed the redirect, the filehandle's already been closed from the
# first time we used it. Thus, we need to probe first to find out what's going on,
# before we start sending any actual data.
########################################################################
sub _send_request_expect_nothing_probed {
########################################################################
my ( $self, @args ) = @_;
my $parameters = get_parameters(@args);
lib/Amazon/S3.pm view on Meta::CPAN
See L<Amazon::S3::BucketV2> for more details.
=item Limited Support for Directory Buckets
This version include limited support for directory buckets.
You can create and list directory buckets.
I<Directory buckets use the S3 Express One Zone storage class, which
is recommended if your application is performance sensitive and
benefits from single-digit millisecond PUT and GET latencies.> -
L<https://docs.aws.amazon.com/AmazonS3/latest/userguide/directory-buckets-overview.html>
=over 10
=item list_directory_buckets
List the directory buckets. Note this only returns a list of you
directory buckets, not their contents. In order to list the contents
of a directory bucket you must first create a session that establishes
temporary credentials used to acces the Zonal endpoints. You then use
lib/Amazon/S3/Bucket.pm view on Meta::CPAN
sub _add_key {
########################################################################
my ( $self, @args ) = @_;
my ( $data, $headers, $key ) = @{ $args[0] }{qw{data headers key}};
my $account = $self->account;
if ( ref $data ) {
return $account->_send_request_expect_nothing_probed(
{ method => 'PUT',
path => $self->_uri($key),
headers => $headers,
data => $data,
region => $self->region,
},
);
}
else {
return $account->_send_request_expect_nothing(
{ method => 'PUT',
path => $self->_uri($key),
headers => $headers,
data => $data,
region => $self->region,
},
);
}
}
########################################################################
lib/Amazon/S3/Bucket.pm view on Meta::CPAN
[ part => $part_number,
length => length $data,
path => $path,
]
);
}
);
my $request = $acct->_make_request(
{ region => $self->region,
method => 'PUT',
path => $self->_uri($key) . $params,
#path => $path,
headers => $headers,
data => $data,
},
);
my $response = $acct->_do_http($request);
$acct->_croak_if_response_error($response);
lib/Amazon/S3/Bucket.pm view on Meta::CPAN
$request_headers{'x-amz-copy-source'} = sprintf '%s/%s', $bucket,
urlencode($source);
}
$request_headers{'x-amz-tagging-directive'} //= 'COPY';
$key = $self->_uri($key);
my $request = $acct->_make_request(
method => 'PUT',
path => $key,
headers => \%request_headers,
);
my $response = $acct->_do_http($request);
if ( $response->code !~ /\A2\d{2}\z/xsm ) {
$acct->_remember_errors( $response->content, 1 );
croak $response->status_line;
}
lib/Amazon/S3/Bucket.pm view on Meta::CPAN
if ( $conf->{acl_short} ) {
$headers->{'x-amz-acl'} //= $conf->{acl_short};
}
my $xml = $conf->{acl_xml} // $EMPTY;
$headers->{'Content-Length'} = length $xml;
return $account->_send_request_expect_nothing(
{ method => 'PUT',
path => $path,
headers => $headers,
data => $xml,
region => $self->region,
},
);
}
########################################################################
sub get_location_constraint {
lib/Amazon/S3/Bucket.pm view on Meta::CPAN
=item public-read
Owner gets FULL_CONTROL and the anonymous principal is
granted READ access. If this policy is used on an object, it
can be read from a browser with no authentication.
=item public-read-write
Owner gets FULL_CONTROL, the anonymous principal is granted
READ and WRITE access. This is a useful policy to apply to a
bucket, if you intend for any anonymous user to PUT objects
into the bucket.
=item authenticated-read
Owner gets FULL_CONTROL, and any principal authenticated as
a registered Amazon S3 user is granted READ access.
=back
=item key
lib/Amazon/S3/BucketV2.pm view on Meta::CPAN
get_bucket_website => 'website',
);
create_methods(
type => 'bucket',
method => 'GET',
method_def => \@GET_BUCKET_METHODS,
);
#######################################################################
our @PUT_BUCKET_METHODS = (
#######################################################################
put_bucket_intelligent_tiering_configuration => 'intelligent-tiering',
put_bucket_cors => 'cors',
put_bucket_replication_configuration => 'replication',
put_bucket_versioning => 'versioning',
put_bucket_encryption => 'encryption',
put_bucket_lifecycle_configuration => 'lifecycle',
put_bucket_lifecycle => 'lifecycle',
put_bucket_tagging => 'tagging',
);
create_methods(
type => 'bucket',
method => 'PUT',
method_def => \@PUT_BUCKET_METHODS
);
######################################################################
our @PUT_OBJECT_METHODS = (
#######################################################################
put_object => $EMPTY,
put_object_acl => 'acl',
put_object_tagging => 'tagging',
put_object_retention => 'retention',
put_object_legal_hold => 'legal-hold',
put_object_lock_configuraiton => 'lock-object',
put_public_access_block => 'publicAccessBlock',
restore_object => sub {
return { method => 'POST', api => 'restore' };
},
upload_part => $EMPTY,
upload_part_copy => $EMPTY,
);
create_methods(
type => 'object',
method => 'PUT',
method_def => \@PUT_OBJECT_METHODS,
);
######################################################################
our @DELETE_OBJECT_METHODS = (
######################################################################
delete_object => $EMPTY,
delete_objects => sub {
return { method => 'POST', api => 'delete' };
},
delete_object_tagging => 'tagging',
lib/Amazon/S3/BucketV2.pm view on Meta::CPAN
# api => name of the API to invoke (example: 'versioning')
# content_key => optional root element for XML serialzation
# headers => optional headers - create a Content-MD5 key in the headers
# object if you want to add the MD5 value
# bucket => optional bucket name
# key => optional key value for APIs that accept a key
# data => optional object that will be converted to an XML payload
# method => HTTP method
#
# NOTES:
# 1. If the 'data' object is included, the default method is 'PUT'
# 2. If no 'data' object is included, the default method is 'GET'
# 3. If 'content_key' is not provided when including a 'data' object
# the method will attempt to guess the root element (content_key)
# when serializing the data object to XML. If you include
# additional elements to be used as query string parameters,
# you should specify 'content_key'..
########################################################################
sub send_request {
########################################################################
my ( $self, @args ) = @_;
( run in 2.242 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )