From 95b94e455f872eaff8de8214b3633dedce979d9c Mon Sep 17 00:00:00 2001 From: Leon Brocard Date: Tue, 30 Mar 2010 11:24:19 +0100 Subject: [PATCH] add content_encoding to Net::Amazon::S3::Object (suggested by Egor Korablev) --- CHANGES | 2 ++ lib/Net/Amazon/S3/Client/Object.pm | 15 +++++++++++++++ t/02client.t | 9 +++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 505c90d4..5b356b21 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,8 @@ Revision history for Perl module Net::Amazon::S3: - add an exists method to Net::Amazon::S3::Client (suggested by David Golden) - fix max_keys when listing buckets (spotted by Andrew Bryan) + - add content_encoding to Net::Amazon::S3::Object (suggested + by Egor Korablev) 0.52 Thu Jul 2 09:17:11 BST 2009 - increase version prerequisites for some modules so that they diff --git a/lib/Net/Amazon/S3/Client/Object.pm b/lib/Net/Amazon/S3/Client/Object.pm index 727494ac..6c2dab57 100644 --- a/lib/Net/Amazon/S3/Client/Object.pm +++ b/lib/Net/Amazon/S3/Client/Object.pm @@ -30,6 +30,11 @@ has 'content_type' => ( required => 0, default => 'binary/octet-stream' ); +has 'content_encoding' => ( + is => 'ro', + isa => 'Str', + required => 0, +); __PACKAGE__->meta->make_immutable; @@ -111,6 +116,9 @@ sub put { $conf->{Expires} = DateTime::Format::HTTP->format_datetime( $self->expires ); } + if ( $self->content_encoding ) { + $conf->{'Content-Encoding'} = $self->content_encoding; + } my $http_request = Net::Amazon::S3::Request::PutObject->new( s3 => $self->client->s3, @@ -154,6 +162,9 @@ sub put_filename { $conf->{Expires} = DateTime::Format::HTTP->format_datetime( $self->expires ); } + if ( $self->content_encoding ) { + $conf->{'Content-Encoding'} = $self->content_encoding; + } my $http_request = Net::Amazon::S3::Request::PutObject->new( s3 => $self->client->s3, @@ -384,6 +395,8 @@ This module represents objects in buckets. ); $object->put('this is the public value'); +You may also set Content-Encoding using content_encoding. + =head2 put_filename # upload a file @@ -402,6 +415,8 @@ This module represents objects in buckets. ); $object->put_filename('hat.jpg'); +You may also set Content-Encoding using content_encoding. + =head2 query_string_authentication_uri # use query string authentication diff --git a/t/02client.t b/t/02client.t index f7d27ffb..72389e85 100644 --- a/t/02client.t +++ b/t/02client.t @@ -146,10 +146,11 @@ $object->delete; # upload a public object $object = $bucket->object( - key => 'this is the public key', - acl_short => 'public-read', - content_type => 'text/plain', - expires => '2001-02-03', + key => 'this is the public key', + acl_short => 'public-read', + content_type => 'text/plain', + content_encoding => 'identity', + expires => '2001-02-03', ); $object->put('this is the public value'); is( get( $object->uri ),