.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Amazon::S3 3pm" .TH Amazon::S3 3pm "2018-08-17" "perl v5.26.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Amazon::S3 \- A portable client library for working with and managing Amazon S3 buckets and keys. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& #!/usr/bin/perl \& use warnings; \& use strict; \& \& use Amazon::S3; \& \& use vars qw/$OWNER_ID $OWNER_DISPLAYNAME/; \& \& my $aws_access_key_id = "Fill me in!"; \& my $aws_secret_access_key = "Fill me in too!"; \& \& my $s3 = Amazon::S3\->new( \& { aws_access_key_id => $aws_access_key_id, \& aws_secret_access_key => $aws_secret_access_key, \& retry => 1 \& } \& ); \& \& my $response = $s3\->buckets; \& \& # create a bucket \& my $bucket_name = $aws_access_key_id . \*(Aq\-net\-amazon\-s3\-test\*(Aq; \& my $bucket = $s3\->add_bucket( { bucket => $bucket_name } ) \& or die $s3\->err . ": " . $s3\->errstr; \& \& # store a key with a content\-type and some optional metadata \& my $keyname = \*(Aqtesting.txt\*(Aq; \& my $value = \*(AqT\*(Aq; \& $bucket\->add_key( \& $keyname, $value, \& { content_type => \*(Aqtext/plain\*(Aq, \& \*(Aqx\-amz\-meta\-colour\*(Aq => \*(Aqorange\*(Aq, \& } \& ); \& \& # list keys in the bucket \& $response = $bucket\->list \& or die $s3\->err . ": " . $s3\->errstr; \& print $response\->{bucket}."\en"; \& for my $key (@{ $response\->{keys} }) { \& print "\et".$key\->{key}."\en"; \& } \& \& # delete key from bucket \& $bucket\->delete_key($keyname); \& \& # delete bucket \& $bucket\->delete_bucket; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Amazon::S3 provides a portable client interface to Amazon Simple Storage System (S3). .PP \&\*(L"Amazon S3 is storage for the Internet. It is designed to make web-scale computing easier for developers. Amazon S3 provides a simple web services interface that can be used to store and retrieve any amount of data, at any time, from anywhere on the web. It gives any developer access to the same highly scalable, reliable, fast, inexpensive data storage infrastructure that Amazon uses to run its own global network of web sites. The service aims to maximize benefits of scale and to pass those benefits on to developers\*(R". .PP To sign up for an Amazon Web Services account, required to use this library and the S3 service, please visit the Amazon Web Services web site at http://www.amazonaws.com/. .PP You will be billed accordingly by Amazon when you use this module and must be responsible for these costs. .PP To learn more about Amazon's S3 service, please visit: http://s3.amazonaws.com/. .PP This need for this module arose from some work that needed to work with S3 and would be distributed, installed and used on many various environments where compiled dependencies may not be an option. Net::Amazon::S3 used XML::LibXML tying it to that specific and often difficult to install option. In order to remove this potential barrier to entry, this module is forked and then modified to use \s-1XML::SAX\s0 via XML::Simple. .PP Amazon::S3 is intended to be a drop-in replacement for that trades some performance in return for portability. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" Create a new S3 client object. Takes some arguments: .IP "aws_access_key_id" 4 .IX Item "aws_access_key_id" Use your Access Key \s-1ID\s0 as the value of the AWSAccessKeyId parameter in requests you send to Amazon Web Services (when required). Your Access Key \s-1ID\s0 identifies you as the party responsible for the request. .IP "aws_secret_access_key" 4 .IX Item "aws_secret_access_key" Since your Access Key \s-1ID\s0 is not encrypted in requests to \s-1AWS,\s0 it could be discovered and used by anyone. Services that are not free require you to provide additional information, a request signature, to verify that a request containing your unique Access Key \s-1ID\s0 could only have come from you. .Sp \&\fB\s-1DO NOT INCLUDE THIS IN SCRIPTS OR APPLICATIONS YOU DISTRIBUTE. YOU\s0'\s-1LL BE SORRY.\s0\fR .IP "secure" 4 .IX Item "secure" Set this to \f(CW1\fR if you want to use SSL-encrypted connections when talking to S3. Defaults to \f(CW0\fR. .IP "timeout" 4 .IX Item "timeout" Defines the time, in seconds, your script should wait or a response before bailing. Defaults is 30 seconds. .IP "retry" 4 .IX Item "retry" Enables or disables the library to retry upon errors. This uses exponential backoff with retries after 1, 2, 4, 8, 16, 32 seconds, as recommended by Amazon. Defaults to off, no retries. .IP "host" 4 .IX Item "host" Defines the S3 host endpoint to use. Defaults to \&'s3.amazonaws.com'. .SS "buckets" .IX Subsection "buckets" Returns \f(CW\*(C`undef\*(C'\fR on error, else \s-1HASHREF\s0 of results: .IP "owner_id" 4 .IX Item "owner_id" The owner's \s-1ID\s0 of the buckets owner. .IP "owner_display_name" 4 .IX Item "owner_display_name" The name of the owner account. .IP "buckets" 4 .IX Item "buckets" Any \s-1ARRAYREF\s0 of Amazon::SimpleDB::Bucket objects for the account. .SS "add_bucket" .IX Subsection "add_bucket" Takes a \s-1HASHREF:\s0 .IP "bucket" 4 .IX Item "bucket" The name of the bucket you want to add .IP "acl_short (optional)" 4 .IX Item "acl_short (optional)" See the set_acl subroutine for documentation on the acl_short options .PP Returns 0 on failure or a Amazon::S3::Bucket object on success .SS "bucket \s-1BUCKET\s0" .IX Subsection "bucket BUCKET" Takes a scalar argument, the name of the bucket you're creating .PP Returns an (unverified) bucket object from an account. This method does not access the network. .SS "delete_bucket" .IX Subsection "delete_bucket" Takes either a Amazon::S3::Bucket object or a \s-1HASHREF\s0 containing .IP "bucket" 4 .IX Item "bucket" The name of the bucket to remove .PP Returns false (and fails) if the bucket isn't empty. .PP Returns true if the bucket is successfully deleted. .SS "list_bucket" .IX Subsection "list_bucket" List all keys in this bucket. .PP Takes a \s-1HASHREF\s0 of arguments: .IP "bucket" 4 .IX Item "bucket" \&\s-1REQUIRED.\s0 The name of the bucket you want to list keys on. .IP "prefix" 4 .IX Item "prefix" Restricts the response to only contain results that begin with the specified prefix. If you omit this optional argument, the value of prefix for your query will be the empty string. In other words, the results will be not be restricted by prefix. .IP "delimiter" 4 .IX Item "delimiter" If this optional, Unicode string parameter is included with your request, then keys that contain the same string between the prefix and the first occurrence of the delimiter will be rolled up into a single result element in the CommonPrefixes collection. These rolled-up keys are not returned elsewhere in the response. For example, with prefix=\*(L"\s-1USA/\*(R"\s0 and delimiter=\*(L"/\*(R", the matching keys \&\*(L"USA/Oregon/Salem\*(R" and \*(L"USA/Oregon/Portland\*(R" would be summarized in the response as a single \*(L"USA/Oregon\*(R" element in the CommonPrefixes collection. If an otherwise matching key does not contain the delimiter after the prefix, it appears in the Contents collection. .Sp Each element in the CommonPrefixes collection counts as one against the MaxKeys limit. The rolled-up keys represented by each CommonPrefixes element do not. If the Delimiter parameter is not present in your request, keys in the result set will not be rolled-up and neither the CommonPrefixes collection nor the NextMarker element will be present in the response. .Sp \&\s-1NOTE:\s0 CommonPrefixes isn't currently supported by Amazon::S3. .IP "max-keys" 4 .IX Item "max-keys" This optional argument limits the number of results returned in response to your query. Amazon S3 will return no more than this number of results, but possibly less. Even if max-keys is not specified, Amazon S3 will limit the number of results in the response. Check the IsTruncated flag to see if your results are incomplete. If so, use the Marker parameter to request the next page of results. For the purpose of counting max-keys, a 'result' is either a key in the 'Contents' collection, or a delimited prefix in the \&'CommonPrefixes' collection. So for delimiter requests, max-keys limits the total number of list results, not just the number of keys. .IP "marker" 4 .IX Item "marker" This optional parameter enables pagination of large result sets. \&\f(CW\*(C`marker\*(C'\fR specifies where in the result set to resume listing. It restricts the response to only contain results that occur alphabetically after the value of marker. To retrieve the next page of results, use the last key from the current page of results as the marker in your next request. .Sp See also \f(CW\*(C`next_marker\*(C'\fR, below. .Sp If \f(CW\*(C`marker\*(C'\fR is omitted,the first page of results is returned. .PP Returns \f(CW\*(C`undef\*(C'\fR on error and a \s-1HASHREF\s0 of data on success: .PP The \s-1HASHREF\s0 looks like this: .PP .Vb 9 \& { \& bucket => $bucket_name, \& prefix => $bucket_prefix, \& marker => $bucket_marker, \& next_marker => $bucket_next_available_marker, \& max_keys => $bucket_max_keys, \& is_truncated => $bucket_is_truncated_boolean \& keys => [$key1,$key2,...] \& } .Ve .PP Explanation of bits of that: .IP "is_truncated" 4 .IX Item "is_truncated" B flag that indicates whether or not all results of your query were returned in this response. If your results were truncated, you can make a follow-up paginated request using the Marker parameter to retrieve the rest of the results. .IP "next_marker" 4 .IX Item "next_marker" A convenience element, useful when paginating with delimiters. The value of \f(CW\*(C`next_marker\*(C'\fR, if present, is the largest (alphabetically) of all key names and all CommonPrefixes prefixes in the response. If the \f(CW\*(C`is_truncated\*(C'\fR flag is set, request the next page of results by setting \f(CW\*(C`marker\*(C'\fR to the value of \f(CW\*(C`next_marker\*(C'\fR. This element is only present in the response if the \f(CW\*(C`delimiter\*(C'\fR parameter was sent with the request. .PP Each key is a \s-1HASHREF\s0 that looks like this: .PP .Vb 9 \& { \& key => $key, \& last_modified => $last_mod_date, \& etag => $etag, # An MD5 sum of the stored content. \& size => $size, # Bytes \& storage_class => $storage_class # Doc? \& owner_id => $owner_id, \& owner_displayname => $owner_name \& } .Ve .SS "list_bucket_all" .IX Subsection "list_bucket_all" List all keys in this bucket without having to worry about \&'marker'. This is a convenience method, but may make multiple requests to S3 under the hood. .PP Takes the same arguments as list_bucket. .SH "ABOUT" .IX Header "ABOUT" This module contains code modified from Amazon that contains the following notice: .PP .Vb 8 \& # This software code is made available "AS IS" without warranties of any \& # kind. You may copy, display, modify and redistribute the software \& # code either by itself or as incorporated into your code; provided that \& # you do not remove any proprietary notices. Your use of this software \& # code is at your own risk and you waive any claim against Amazon \& # Digital Services, Inc. or its affiliates with respect to your use of \& # this software code. (c) 2006 Amazon Digital Services, Inc. or its \& # affiliates. .Ve .SH "TESTING" .IX Header "TESTING" Testing S3 is a tricky thing. Amazon wants to charge you a bit of money each time you use their service. And yes, testing counts as using. Because of this, the application's test suite skips anything approaching a real test unless you set these three environment variables: .IP "\s-1AMAZON_S3_EXPENSIVE_TESTS\s0" 4 .IX Item "AMAZON_S3_EXPENSIVE_TESTS" Doesn't matter what you set it to. Just has to be set .IP "\s-1AWS_ACCESS_KEY_ID\s0" 4 .IX Item "AWS_ACCESS_KEY_ID" Your \s-1AWS\s0 access key .IP "\s-1AWS_ACCESS_KEY_SECRET\s0" 4 .IX Item "AWS_ACCESS_KEY_SECRET" Your \s-1AWS\s0 sekkr1t passkey. Be forewarned that setting this environment variable on a shared system might leak that information to another user. Be careful. .SH "TO DO" .IX Header "TO DO" .IP "Continued to improve and refine of documentation." 4 .IX Item "Continued to improve and refine of documentation." .PD 0 .IP "Reduce dependencies wherever possible." 4 .IX Item "Reduce dependencies wherever possible." .IP "Implement debugging mode" 4 .IX Item "Implement debugging mode" .IP "Refactor and consolidate request code in Amazon::S3" 4 .IX Item "Refactor and consolidate request code in Amazon::S3" .IP "Refactor \s-1URI\s0 creation code to make use of \s-1URI\s0." 4 .IX Item "Refactor URI creation code to make use of URI." .PD .SH "SUPPORT" .IX Header "SUPPORT" Bugs should be reported via the \s-1CPAN\s0 bug tracker at .PP .PP For other issues, contact the author. .SH "AUTHOR" .IX Header "AUTHOR" Timothy Appnel .SH "SEE ALSO" .IX Header "SEE ALSO" Amazon::S3::Bucket, Net::Amazon::S3 .SH "COPYRIGHT AND LICENCE" .IX Header "COPYRIGHT AND LICENCE" This module was initially based on Net::Amazon::S3 0.41, by Leon Brocard. Net::Amazon::S3 was based on example code from Amazon with this notice: .PP # This software code is made available \*(L"\s-1AS IS\*(R"\s0 without warranties of any # kind. You may copy, display, modify and redistribute the software # code either by itself or as incorporated into your code; provided that # you do not remove any proprietary notices. Your use of this software # code is at your own risk and you waive any claim against Amazon # Digital Services, Inc. or its affiliates with respect to your use of # this software code. (c) 2006 Amazon Digital Services, Inc. or its # affiliates. .PP The software is released under the Artistic License. The terms of the Artistic License are described at http://www.perl.com/language/misc/Artistic.html. Except where otherwise noted, Amazon::S3 is Copyright 2008, Timothy Appnel, tima@cpan.org. All rights reserved.