NAME
Net::Amazon::S3::Client::Object - An easy-to-use Amazon S3 client object
VERSION
version 0.991
SYNOPSIS
print $object ->key . "\n" ;
print $object ->etag . "\n" ;
print $object ->size . "\n" ;
my $object = $bucket ->object( key => 'this is the key' );
$object ->put( 'this is the value' );
my $value = $object ->get;
my %metadata = %{ $object ->head};
if ( $object -> exists ) { ... }
$object -> delete ;
my $object = $bucket ->object(
key => 'this is the public key' ,
acl => Net::Amazon::S3::ACL::CANNED->PUBLIC_READ,
content_type => 'text/plain' ,
expires => '2010-01-02' ,
);
$object ->put( 'this is the public value' );
my $uri = $object ->uri;
$object ->available;
$object ->restore(
days => 1,
tier => 'Standard' ,
);
my $object = $bucket ->object(
key => 'my secret' ,
encryption => 'AES256' ,
);
$object ->put( 'this data will be stored using encryption.' );
my $object = $bucket ->object(
key => 'images/my_hat.jpg' ,
content_type => 'image/jpeg' ,
);
$object ->put_filename( 'hat.jpg' );
my $object = $bucket ->object(
key => 'images/my_hat.jpg' ,
content_type => 'image/jpeg' ,
etag => $md5_hex ,
size => $size ,
);
$object ->put_filename( 'hat.jpg' );
my $object = $bucket ->object( key => 'images/my_hat.jpg' );
$object ->get_filename( 'hat_backup.jpg' );
my $object = $bucket ->object(
key => 'images/my_hat.jpg' ,
expires => '2009-03-01' ,
);
my $uri = $object ->query_string_authentication_uri();
my $object = $bucket ->object(
key => 'images/my_hat.jpg' ,
expires => '2009-03-01' ,
);
my $uri = $object ->query_string_authentication_uri_for_method( 'PUT' );
|
DESCRIPTION
This module represents objects in buckets.
METHODS
range
my $value = $object ->range ( 'bytes=1024-10240' )->get;
|
Provides simple interface to ranged download. See also Net::Amazon::S3::Client::Object::Range.
etag
print $object ->etag . "\n" ;
|
delete
exists
if ( $object -> exists ) { ... }
|
Method doesn't report error when bucket or key doesn't exist.
get
my $value = $object ->get;
|
head
my %metadata = %{ $object ->head};
|
Unlike exists
this method does report error.
get_decoded
my $value = $object ->get_decoded;
|
get_filename
my $object = $bucket ->object( key => 'images/my_hat.jpg' );
$object ->get_filename( 'hat_backup.jpg' );
|
last_modified, last_modified_raw
my $dt = $obj ->last_modified;
my $raw = $obj ->last_modified_raw;
|
key
print $object ->key . "\n" ;
|
available
restore
$object ->restore(
days => 1,
tier => 'Standard' ,
);
|
put
my $object = $bucket ->object( key => 'this is the key' );
$object ->put( 'this is the value' );
my $object = $bucket ->object(
key => 'this is the public key' ,
acl => 'public-read' ,
content_type => 'text/plain' ,
);
$object ->put( 'this is the public value' );
|
For acl
refer Net::Amazon::S3::ACL.
You may also set Content-Encoding using content_encoding
, and Content-Disposition using content_disposition
.
You may specify the S3 storage class by setting storage_class
to either standard
, reduced_redundancy
, standard_ia
, onezone_ia
, intelligent_tiering
, glacier
, or deep_archive
; the default is standard
.
You may set website-redirect-location object metadata by setting website_redirect_location
to either another object name in the same bucket, or to an external URL.
put_filename
my $object = $bucket ->object(
key => 'images/my_hat.jpg' ,
content_type => 'image/jpeg' ,
);
$object ->put_filename( 'hat.jpg' );
my $object = $bucket ->object(
key => 'images/my_hat.jpg' ,
content_type => 'image/jpeg' ,
etag => $md5_hex ,
size => $size ,
);
$object ->put_filename( 'hat.jpg' );
|
You may also set Content-Encoding using content_encoding
, and Content-Disposition using content_disposition
.
You may specify the S3 storage class by setting storage_class
to either standard
, reduced_redundancy
, standard_ia
, onezone_ia
, intelligent_tiering
, glacier
, or deep_archive
; the default is standard
.
You may set website-redirect-location object metadata by setting website_redirect_location
to either another object name in the same bucket, or to an external URL.
User metadata may be set by providing a non-empty hashref as user_metadata
.
query_string_authentication_uri
my $object = $bucket ->object(
key => 'images/my_hat.jpg' ,
expires => '2009-03-01' ,
);
my $uri = $object ->query_string_authentication_uri({
'response-content-disposition' => 'attachment; filename=abc.doc' ,
});
|
query_string_authentication_uri_for_method
my $uri = $object ->query_string_authentication_uri_for_method ( 'PUT' );
|
Similar to "query_string_authentication_uri" but creates presigned uri for specified HTTP method (Signature V4 uses also HTTP method).
Methods providee authenticated uri only for direct object operations.
See https://docs.aws.amazon.com/AmazonS3/latest/dev/PresignedUrlUploadObject.html
size
print $object ->size . "\n" ;
|
uri
initiate_multipart_upload
my $object = $bucket ->object(
key => 'massive_video.avi' ,
acl => ...,
);
my $upload_id = $object ->initiate_multipart_upload;
|
For description of acl
refer Net::Amazon::S3::ACL
.
put_part
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_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.
|
my $object = $bucket ->object( key => $key );
my $content = $object ->get;
my $user_metadata = $object ->user_metadata;
|
To upload an object with user metadata, set user_metadata
at construction time to a hashref, with no x-amz-meta-
prefixes on the key names. When downloading an object, the get
, get_decoded
and get_filename
ethods set the contents of user_metadata
to the same format.
$object ->add_tags (
tags => { tag1 => 'val1' , tag2 => 'val2' },
);
$object ->add_tags (
tags => { tag1 => 'val1' , tag2 => 'val2' },
version_id => $version_id ,
);
|
$object ->delete_tags;
$object ->delete_tags (
version_id => $version_id ,
);
|
AUTHOR
Branislav Zahradník <barney@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2022 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.