1Net::Amazon::S3::ClientU(s3e)r Contributed Perl DocumentaNteito:n:Amazon::S3::Client(3)
2
3
4
6 Net::Amazon::S3::Client - An easy-to-use Amazon S3 client
7
9 my $s3 = Net::Amazon::S3->new(
10 aws_access_key_id => $aws_access_key_id,
11 aws_secret_access_key => $aws_secret_access_key,
12 retry => 1,
13 );
14 my $client = Net::Amazon::S3::Client->new( s3 => $s3 );
15
16 # list all my buckets
17 # returns a list of L<Net::Amazon::S3::Client::Bucket> objects
18 my @buckets = $client->buckets;
19 foreach my $bucket (@buckets) {
20 print $bucket->name . "\n";
21 }
22
23 # create a new bucket
24 # returns a L<Net::Amazon::S3::Client::Bucket> object
25 my $bucket = $client->create_bucket(
26 name => $bucket_name,
27 acl_short => 'private',
28 location_constraint => 'US',
29 );
30
31 # or use an existing bucket
32 # returns a L<Net::Amazon::S3::Client::Bucket> object
33 my $bucket = $client->bucket( name => $bucket_name );
34
36 The Net::Amazon::S3 module was written when the Amazon S3 service had
37 just come out and it is a light wrapper around the APIs. Some bad API
38 decisions were also made. The Net::Amazon::S3::Client,
39 Net::Amazon::S3::Client::Bucket and Net::Amazon::S3::Client::Object
40 classes are designed after years of usage to be easy to use for common
41 tasks.
42
43 These classes throw an exception when a fatal error occurs. It also is
44 very careful to pass an MD5 of the content when uploaded to S3 and
45 check the resultant ETag.
46
47 WARNING: This is an early release of the Client classes, the APIs may
48 change.
49
51 buckets
52 # list all my buckets
53 # returns a list of L<Net::Amazon::S3::Client::Bucket> objects
54 my @buckets = $client->buckets;
55 foreach my $bucket (@buckets) {
56 print $bucket->name . "\n";
57 }
58
59 create_bucket
60 # create a new bucket
61 # returns a L<Net::Amazon::S3::Client::Bucket> object
62 my $bucket = $client->create_bucket(
63 name => $bucket_name,
64 acl_short => 'private',
65 location_constraint => 'US',
66 );
67
68 bucket
69 # or use an existing bucket
70 # returns a L<Net::Amazon::S3::Client::Bucket> object
71 my $bucket = $client->bucket( name => $bucket_name );
72
73
74
75perl v5.12.3 2010-03-30 Net::Amazon::S3::Client(3)