Skip to content

Commit

Permalink
add content_encoding to Net::Amazon::S3::Object (suggested by Egor Ko…
Browse files Browse the repository at this point in the history
…rablev)
  • Loading branch information
acme committed Mar 30, 2010
1 parent a51659b commit 95b94e4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions lib/Net/Amazon/S3/Client/Object.pm
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions t/02client.t
Expand Up @@ -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 ),
Expand Down

0 comments on commit 95b94e4

Please sign in to comment.