File Coverage

lib/AnyEvent/Net/Amazon/S3/Client/Object.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package AnyEvent::Net::Amazon::S3::Client::Object;
2              
3             # ABSTRACT: An easy-to-use Amazon S3 client object
4             our $VERSION = 'v0.04.0.80'; # VERSION
5              
6 1     1   2442 use strict;
  1         2  
  1         35  
7 1     1   4 use warnings;
  1         1  
  1         52  
8              
9             # TODO: _content_sub might become more async manner?
10             # NOTE: exists and delete have HIGH risk.
11 1         9 use Module::AnyEvent::Helper::Filter -as => __PACKAGE__, -target => 'Net::Amazon::S3::Client::Object',
12             -transformer => 'Net::Amazon::S3::Client::Object',
13             -translate_func => [qw(exists _get get get_decoded get_filename _put put put_filename delete
14             initiate_multipart_upload complete_multipart_upload abort_multipart_upload put_part)],
15             -replace_func => [qw(_send_request_raw _send_request _send_request_xpc)]
16 1     1   4 ;
  1         1  
17              
18             1;
19              
20             __END__
21              
22             =pod
23              
24             =encoding UTF-8
25              
26             =head1 NAME
27              
28             AnyEvent::Net::Amazon::S3::Client::Object - An easy-to-use Amazon S3 client object
29              
30             =head1 VERSION
31              
32             version v0.04.0.80
33              
34             =head1 SYNOPSIS
35              
36             # show the key
37             print $object->key . "\n";
38              
39             # show the etag of an existing object (if fetched by listing
40             # a bucket)
41             print $object->etag . "\n";
42              
43             # show the size of an existing object (if fetched by listing
44             # a bucket)
45             print $object->size . "\n";
46              
47             # to create a new object
48             my $object = $bucket->object( key => 'this is the key' );
49             $object->put('this is the value');
50              
51             # to get the vaue of an object
52             my $value = $object->get;
53              
54             # to see if an object exists
55             if ($object->exists) { ... }
56              
57             # to delete an object
58             $object->delete;
59              
60             # to create a new object which is publically-accessible with a
61             # content-type of text/plain which expires on 2010-01-02
62             my $object = $bucket->object(
63             key => 'this is the public key',
64             acl_short => 'public-read',
65             content_type => 'text/plain',
66             expires => '2010-01-02',
67             );
68             $object->put('this is the public value');
69              
70             # return the URI of a publically-accessible object
71             my $uri = $object->uri;
72              
73             # to store a new object with server-side encryption enabled
74             my $object = $bucket->object(
75             key => 'my secret',
76             encryption => 'AES256',
77             );
78             $object->put('this data will be stored using encryption.');
79              
80             # upload a file
81             my $object = $bucket->object(
82             key => 'images/my_hat.jpg',
83             content_type => 'image/jpeg',
84             );
85             $object->put_filename('hat.jpg');
86              
87             # upload a file if you already know its md5_hex and size
88             my $object = $bucket->object(
89             key => 'images/my_hat.jpg',
90             content_type => 'image/jpeg',
91             etag => $md5_hex,
92             size => $size,
93             );
94             $object->put_filename('hat.jpg');
95              
96             # download the value of the object into a file
97             my $object = $bucket->object( key => 'images/my_hat.jpg' );
98             $object->get_filename('hat_backup.jpg');
99              
100             # use query string authentication
101             my $object = $bucket->object(
102             key => 'images/my_hat.jpg',
103             expires => '2009-03-01',
104             );
105             my $uri = $object->query_string_authentication_uri();
106              
107             =head1 DESCRIPTION
108              
109             This module represents objects in buckets.
110              
111             This module provides the same interface as L<Net::Amazon::S3::Client::Object>.
112             In addition, some asynchronous methods returning AnyEvent condition variable are added.
113              
114             =for test_synopsis no strict 'vars';
115             no warnings;
116              
117             =head1 METHODS
118              
119             All L<Net::Amazon::S3::Client::Bucket> methods are available.
120             In addition, there are the following asynchronous methods.
121             Arguments of the methods are identical as original but return value becomes L<AnyEvent> condition variable.
122             You can get actual return value by calling C<shift-E<gt>recv()>.
123              
124             =over 4
125              
126             =item delete_async
127              
128             =item exists_async
129              
130             =item get_async
131              
132             =item get_decoded_async
133              
134             =item get_filename_async
135              
136             =item put_async
137              
138             =item put_filename_async
139              
140             =item complete_multipart_upload_async
141              
142             =item initiate_multipart_upload_async
143              
144             =item abort_multipart_upload_async
145              
146             =item put_part_async
147              
148             =back
149              
150             =for Pod::Coverage list_parts
151             query_string_authentication_uri
152             uri
153             get_callback
154              
155             =head1 AUTHOR
156              
157             Yasutaka ATARASHI <yakex@cpan.org>
158              
159             =head1 COPYRIGHT AND LICENSE
160              
161             This software is copyright (c) 2012 by Yasutaka ATARASHI.
162              
163             This is free software; you can redistribute it and/or modify it under
164             the same terms as the Perl 5 programming language system itself.
165              
166             =cut