| 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.03.0.60'; # VERSION |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
2666
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
41
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
78
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# TODO: _content_sub might become more async manner? |
|
10
|
|
|
|
|
|
|
# NOTE: exists and delete have HIGH risk. |
|
11
|
1
|
|
|
|
|
14
|
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 put_part)], |
|
15
|
|
|
|
|
|
|
-replace_func => [qw(_send_request_raw _send_request _send_request_xpc)] |
|
16
|
1
|
|
|
1
|
|
6
|
; |
|
|
1
|
|
|
|
|
2
|
|
|
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.03.0.60 |
|
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
|
|
|
|
|
|
|
# upload a file |
|
74
|
|
|
|
|
|
|
my $object = $bucket->object( |
|
75
|
|
|
|
|
|
|
key => 'images/my_hat.jpg', |
|
76
|
|
|
|
|
|
|
content_type => 'image/jpeg', |
|
77
|
|
|
|
|
|
|
); |
|
78
|
|
|
|
|
|
|
$object->put_filename('hat.jpg'); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# upload a file if you already know its md5_hex and size |
|
81
|
|
|
|
|
|
|
my $object = $bucket->object( |
|
82
|
|
|
|
|
|
|
key => 'images/my_hat.jpg', |
|
83
|
|
|
|
|
|
|
content_type => 'image/jpeg', |
|
84
|
|
|
|
|
|
|
etag => $md5_hex, |
|
85
|
|
|
|
|
|
|
size => $size, |
|
86
|
|
|
|
|
|
|
); |
|
87
|
|
|
|
|
|
|
$object->put_filename('hat.jpg'); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# download the value of the object into a file |
|
90
|
|
|
|
|
|
|
my $object = $bucket->object( key => 'images/my_hat.jpg' ); |
|
91
|
|
|
|
|
|
|
$object->get_filename('hat_backup.jpg'); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# use query string authentication |
|
94
|
|
|
|
|
|
|
my $object = $bucket->object( |
|
95
|
|
|
|
|
|
|
key => 'images/my_hat.jpg', |
|
96
|
|
|
|
|
|
|
expires => '2009-03-01', |
|
97
|
|
|
|
|
|
|
); |
|
98
|
|
|
|
|
|
|
my $uri = $object->query_string_authentication_uri(); |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This module represents objects in buckets. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This module provides the same interface as L<Net::Amazon::S3::Client::Object>. |
|
105
|
|
|
|
|
|
|
In addition, some asynchronous methods returning AnyEvent condition variable are added. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=for test_synopsis no strict 'vars'; |
|
108
|
|
|
|
|
|
|
no warnings; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 METHODS |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
All L<Net::Amazon::S3::Client::Bucket> methods are available. |
|
113
|
|
|
|
|
|
|
In addition, there are the following asynchronous methods. |
|
114
|
|
|
|
|
|
|
Arguments of the methods are identical as original but return value becomes L<AnyEvent> condition variable. |
|
115
|
|
|
|
|
|
|
You can get actual return value by calling C<shift-E<gt>recv()>. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over 4 |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item delete_async |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item exists_async |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item get_async |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item get_decoded_async |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item get_filename_async |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item put_async |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item put_filename_async |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item complete_multipart_upload_async |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item initiate_multipart_upload_async |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item put_part_async |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=for Pod::Coverage list_parts |
|
142
|
|
|
|
|
|
|
query_string_authentication_uri |
|
143
|
|
|
|
|
|
|
uri |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHOR |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Yasutaka ATARASHI <yakex@cpan.org> |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Yasutaka ATARASHI. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
154
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |