.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" 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 turned on, 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 .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Net::Amazon::S3 3pm" .TH Net::Amazon::S3 3pm "2014-05-11" "perl v5.18.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" Net::Amazon::S3 \- Use the Amazon S3 \- Simple Storage Service .SH "VERSION" .IX Header "VERSION" version 0.60 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Net::Amazon::S3; \& my $aws_access_key_id = \*(Aqfill me in\*(Aq; \& my $aws_secret_access_key = \*(Aqfill me in too\*(Aq; \& \& my $s3 = Net::Amazon::S3\->new( \& { aws_access_key_id => $aws_access_key_id, \& aws_secret_access_key => $aws_secret_access_key, \& retry => 1, \& } \& ); \& \& # a bucket is a globally\-unique directory \& # list all buckets that i own \& my $response = $s3\->buckets; \& foreach my $bucket ( @{ $response\->{buckets} } ) { \& print "You have a bucket: " . $bucket\->bucket . "\en"; \& } \& \& # create a new bucket \& my $bucketname = \*(Aqacmes_photo_backups\*(Aq; \& my $bucket = $s3\->add_bucket( { bucket => $bucketname } ) \& or die $s3\->err . ": " . $s3\->errstr; \& \& # or use an existing bucket \& $bucket = $s3\->bucket($bucketname); \& \& # store a file in the bucket \& $bucket\->add_key_filename( \*(Aq1.JPG\*(Aq, \*(AqDSC06256.JPG\*(Aq, \& { content_type => \*(Aqimage/jpeg\*(Aq, }, \& ) or die $s3\->err . ": " . $s3\->errstr; \& \& # store a value in the bucket \& $bucket\->add_key( \*(Aqreminder.txt\*(Aq, \*(Aqthis is where my photos are backed up\*(Aq ) \& or die $s3\->err . ": " . $s3\->errstr; \& \& # list files in the bucket \& $response = $bucket\->list_all \& or die $s3\->err . ": " . $s3\->errstr; \& foreach my $key ( @{ $response\->{keys} } ) { \& my $key_name = $key\->{key}; \& my $key_size = $key\->{size}; \& print "Bucket contains key \*(Aq$key_name\*(Aq of size $key_size\en"; \& } \& \& # fetch file from the bucket \& $response = $bucket\->get_key_filename( \*(Aq1.JPG\*(Aq, \*(AqGET\*(Aq, \*(Aqbackup.jpg\*(Aq ) \& or die $s3\->err . ": " . $s3\->errstr; \& \& # fetch value from the bucket \& $response = $bucket\->get_key(\*(Aqreminder.txt\*(Aq) \& or die $s3\->err . ": " . $s3\->errstr; \& print "reminder.txt:\en"; \& print " content length: " . $response\->{content_length} . "\en"; \& print " content type: " . $response\->{content_type} . "\en"; \& print " etag: " . $response\->{content_type} . "\en"; \& print " content: " . $response\->{value} . "\en"; \& \& # delete keys \& $bucket\->delete_key(\*(Aqreminder.txt\*(Aq) or die $s3\->err . ": " . $s3\->errstr; \& $bucket\->delete_key(\*(Aq1.JPG\*(Aq) or die $s3\->err . ": " . $s3\->errstr; \& \& # and finally delete the bucket \& $bucket\->delete_bucket or die $s3\->err . ": " . $s3\->errstr; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides a Perlish interface to Amazon S3. From the developer blurb: \*(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 find out more about S3, please visit: http://s3.amazonaws.com/ .PP To use this module you will need to sign up to Amazon Web Services and provide an \*(L"Access Key \s-1ID\*(R"\s0 and \*(L" Secret Access Key\*(R". If you use this module, you will incurr costs as specified by Amazon. Please check the costs. If you use this module with your Access Key \s-1ID\s0 and Secret Access Key you must be responsible for these costs. .PP I highly recommend reading all about S3, but in a nutshell data is stored in values. Values are referenced by keys, and keys are stored in buckets. Bucket names are global. .PP Note: This is the legacy interface, please check out Net::Amazon::S3::Client instead. .PP Development of this code happens here: http://github.com/pfig/net\-amazon\-s3/ .PP Homepage for the project (just started) is at http://pfig.github.com/net\-amazon\-s3/ .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 \&\s-1DO NOT INCLUDE THIS IN SCRIPTS OR APPLICATIONS YOU DISTRIBUTE. YOU\s0'\s-1LL BE SORRY\s0 .IP "aws_session_token" 4 .IX Item "aws_session_token" If you are using temporary credentials provided by the \s-1AWS\s0 Security Token Service, set the token here, and it will be added to the request in order to authenticate it. .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" How many seconds should your script wait before bailing on a request to S3? Defaults to 30. .IP "retry" 4 .IX Item "retry" If this library should retry upon errors. This option is recommended. This uses exponential backoff with retries after 1, 2, 4, 8, 16, 32 seconds, as recommended by Amazon. Defaults to off. .SS "buckets" .IX Subsection "buckets" Returns undef on error, else hashref of results .SS "add_bucket" .IX Subsection "add_bucket" Takes a hashref: .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 documenation on the acl_short options .IP "location_constraint (option)" 4 .IX Item "location_constraint (option)" Sets the location constraint of the new bucket. If left unspecified, the default S3 datacenter location will be used. Otherwise, you can set it to '\s-1EU\s0' for a European data center \- note that costs are different. .PP Returns 0 on failure, Net::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. Does no network access. .SS "delete_bucket" .IX Subsection "delete_bucket" Takes either a Net::Amazon::S3::Bucket object or a hashref 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 hashref of arguments: .PP \&\s-1MANDATORY\s0 .IP "bucket" 4 .IX Item "bucket" The name of the bucket you want to list keys on .PP \&\s-1OPTIONAL\s0 .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. .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 undef on error and a hashref of data on success: .PP The hashref looks like this: .PP .Vb 10 \& { \& bucket => $bucket_name, \& prefix => $bucket_prefix, \& common_prefixes => [$prefix1,$prefix2,...] \& 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 "common_prefixes" 4 .IX Item "common_prefixes" If list_bucket was requested with a delimiter, common_prefixes will contain a list of prefixes matching that delimiter. Drill down into these prefixes by making another request with the prefix parameter. .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 hashref 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. .SS "add_key" .IX Subsection "add_key" \&\s-1DEPRECATED. DO NOT USE\s0 .SS "get_key" .IX Subsection "get_key" \&\s-1DEPRECATED. DO NOT USE\s0 .SS "head_key" .IX Subsection "head_key" \&\s-1DEPRECATED. DO NOT USE\s0 .SS "delete_key" .IX Subsection "delete_key" \&\s-1DEPRECATED. DO NOT USE\s0 .SH "LICENSE" .IX Header "LICENSE" 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 "AUTHOR" .IX Header "AUTHOR" Leon Brocard and unknown Amazon Digital Services programmers. .PP Brad Fitzpatrick \- return values, Bucket object .PP Pedro Figueiredo \- since 0.54 .SH "SEE ALSO" .IX Header "SEE ALSO" Net::Amazon::S3::Bucket .SH "AUTHOR" .IX Header "AUTHOR" Pedro Figueiredo .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2014 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.