Net::Amazon::S3::Client::Object - An easy-to-use Amazon S3 client object
version 0.59
# show the key print $object->key . "\n"; # show the etag of an existing object (if fetched by listing # a bucket) print $object->etag . "\n"; # show the size of an existing object (if fetched by listing # a bucket) print $object->size . "\n"; # to create a new object my $object = $bucket->object( key => 'this is the key' ); $object->put('this is the value'); # to get the vaue of an object my $value = $object->get; # to see if an object exists if ($object->exists) { ... } # to delete an object $object->delete; # to create a new object which is publically-accessible with a # content-type of text/plain which expires on 2010-01-02 my $object = $bucket->object( key => 'this is the public key', acl_short => 'public-read', content_type => 'text/plain', expires => '2010-01-02', ); $object->put('this is the public value'); # return the URI of a publically-accessible object my $uri = $object->uri; # upload a file my $object = $bucket->object( key => 'images/my_hat.jpg', content_type => 'image/jpeg', ); $object->put_filename('hat.jpg'); # upload a file if you already know its md5_hex and size my $object = $bucket->object( key => 'images/my_hat.jpg', content_type => 'image/jpeg', etag => $md5_hex, size => $size, ); $object->put_filename('hat.jpg'); # download the value of the object into a file my $object = $bucket->object( key => 'images/my_hat.jpg' ); $object->get_filename('hat_backup.jpg'); # use query string authentication my $object = $bucket->object( key => 'images/my_hat.jpg', expires => '2009-03-01', ); my $uri = $object->query_string_authentication_uri();
This module represents objects in buckets.
# show the etag of an existing object (if fetched by listing # a bucket) print $object->etag . "\n";
# to delete an object $object->delete;
# to see if an object exists if ($object->exists) { ... }
# to get the vaue of an object my $value = $object->get;
# download the value of the object into a file my $object = $bucket->object( key => 'images/my_hat.jpg' ); $object->get_filename('hat_backup.jpg');
# show the key print $object->key . "\n";
# to create a new object my $object = $bucket->object( key => 'this is the key' ); $object->put('this is the value'); # to create a new object which is publically-accessible with a # content-type of text/plain my $object = $bucket->object( key => 'this is the public key', acl_short => 'public-read', content_type => 'text/plain', ); $object->put('this is the public value');
You may also set Content-Encoding using content_encoding, and Content-Disposition using content_disposition.
# upload a file my $object = $bucket->object( key => 'images/my_hat.jpg', content_type => 'image/jpeg', ); $object->put_filename('hat.jpg'); # upload a file if you already know its md5_hex and size my $object = $bucket->object( key => 'images/my_hat.jpg', content_type => 'image/jpeg', etag => $md5_hex, size => $size, ); $object->put_filename('hat.jpg');
# use query string authentication my $object = $bucket->object( key => 'images/my_hat.jpg', expires => '2009-03-01', ); my $uri = $object->query_string_authentication_uri();
# show the size of an existing object (if fetched by listing # a bucket) print $object->size . "\n";
# return the URI of a publically-accessible object my $uri = $object->uri;
#initiate a new multipart upload for this object my $object = $bucket->object( key => 'massive_video.avi' ); my $upload_id = $object->initiate_multipart_upload;
#add a part to a multipart upload my $put_part_response = $object->put_part( upload_id => $upload_id, part_number => 1, value => $chunk_content, ); my $part_etag = $put_part_response->header('ETag') Returns an L<HTTP::Response> object. It is necessary to keep the ETags for each part, as these are required to complete the upload.
#complete a multipart upload $object->complete_multipart_upload( upload_id => $upload_id, etags => [$etag_1, $etag_2], part_numbers => [$part_number_1, $part_number2], ); The etag and part_numbers parameters are ordered lists specifying the part numbers and ETags for each individual part of the multipart upload.
Pedro Figueiredo <me@pedrofigueiredo.org>
This software is copyright (c) 2013 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Net::Amazon::S3, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Amazon::S3
CPAN shell
perl -MCPAN -e shell install Net::Amazon::S3
For more information on module installation, please visit the detailed CPAN module installation guide.