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 version 0.991
10
12 # Build Client instance
13 my $client = Net::Amazon::S3::Client->new (
14 # accepts all Net::Amazon::S3's arguments
15 aws_access_key_id => $aws_access_key_id,
16 aws_secret_access_key => $aws_secret_access_key,
17 retry => 1,
18 );
19
20 # or reuse an existing S3 connection
21 my $client = Net::Amazon::S3::Client->new (s3 => $s3);
22
23 # list all my buckets
24 # returns a list of L<Net::Amazon::S3::Client::Bucket> objects
25 my @buckets = $client->buckets;
26 foreach my $bucket (@buckets) {
27 print $bucket->name . "\n";
28 }
29
30 # create a new bucket
31 # returns a L<Net::Amazon::S3::Client::Bucket> object
32 my $bucket = $client->create_bucket(
33 name => $bucket_name,
34 acl_short => 'private',
35 location_constraint => 'us-east-1',
36 );
37
38 # or use an existing bucket
39 # returns a L<Net::Amazon::S3::Client::Bucket> object
40 my $bucket = $client->bucket( name => $bucket_name );
41
43 The Net::Amazon::S3 module was written when the Amazon S3 service had
44 just come out and it is a light wrapper around the APIs. Some bad API
45 decisions were also made. The Net::Amazon::S3::Client,
46 Net::Amazon::S3::Client::Bucket and Net::Amazon::S3::Client::Object
47 classes are designed after years of usage to be easy to use for common
48 tasks.
49
50 These classes throw an exception when a fatal error occurs. It also is
51 very careful to pass an MD5 of the content when uploaded to S3 and
52 check the resultant ETag.
53
54 WARNING: This is an early release of the Client classes, the APIs may
55 change.
56
58 s3 Net::Amazon::S3 instance
59
60 error_handler_class
61 Error handler class name (package name), see
62 Net::Amazon::S3::Error::Handler for more. Overrides one available
63 in "s3".
64
65 Default: Net::Amazon::S3::Error::Handler::Confess
66
67 error_handler
68 Instance of error handler class.
69
71 new
72 Net::Amazon::S3::Client can be constructed two ways.
73
74 Historically it wraps S3 API instance
75
76 use Net::Amazon::S3::Client;
77
78 my $client = Net::Amazon::S3::Client->new (
79 s3 => .... # Net::Amazon::S3 instance
80 );
81
82 new (since v0.92)
83 Since v0.92 explicit creation of S3 API instance is no longer
84 necessary. Net::Amazon::S3::Client's constructor accepts same
85 parameters as Net::Amazon::S3
86
87 use Net::Amazon::S3::Client v0.92;
88
89 my $client = Net::Amazon::S3::Client->new (
90 aws_access_key_id => ...,
91 aws_secret_access_key => ...,
92 ...,
93 );
94
95 buckets
96 # list all my buckets
97 # returns a list of L<Net::Amazon::S3::Client::Bucket> objects
98 my @buckets = $client->buckets;
99 foreach my $bucket (@buckets) {
100 print $bucket->name . "\n";
101 }
102
103 create_bucket
104 # create a new bucket
105 # returns a L<Net::Amazon::S3::Client::Bucket> object
106 my $bucket = $client->create_bucket(
107 name => $bucket_name,
108 acl_short => 'private',
109 location_constraint => 'us-east-1',
110 );
111
112 bucket
113 # or use an existing bucket
114 # returns a L<Net::Amazon::S3::Client::Bucket> object
115 my $bucket = $client->bucket( name => $bucket_name );
116
117 bucket_class
118 # returns string "Net::Amazon::S3::Client::Bucket"
119 # subclasses will want to override this.
120 my $bucket_class = $client->bucket_class
121
123 Branislav ZahradnĂk <barney@cpan.org>
124
126 This software is copyright (c) 2022 by Amazon Digital Services, Leon
127 Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav
128 ZahradnĂk.
129
130 This is free software; you can redistribute it and/or modify it under
131 the same terms as the Perl 5 programming language system itself.
132
133
134
135perl v5.36.0 2023-03-22 Net::Amazon::S3::Client(3)