NAME

AnyEvent::Net::Amazon::S3::Bucket - convenience object for working with Amazon S3 buckets

VERSION

version v0.04.0.80

SYNOPSIS

use AnyEvent::Net::Amazon::S3;

my $bucket = $s3->bucket("foo");

ok($bucket->add_key("key", "data"));
ok($bucket->add_key("key", "data", {
   content_type => "text/html",
  'x-amz-meta-colour' => 'orange',
}));

# the err and errstr methods just proxy up to the AnyEvent::Net::Amazon::S3's
# objects err/errstr methods.
$bucket->add_key("bar", "baz") or
    die $bucket->err . $bucket->errstr;

# fetch a key
$val = $bucket->get_key("key");
is( $val->{value},               'data' );
is( $val->{content_type},        'text/html' );
is( $val->{etag},                'b9ece18c950afbfa6b0fdbfa4ff731d3' );
is( $val->{'x-amz-meta-colour'}, 'orange' );

# returns undef on missing or on error (check $bucket->err)
is(undef, $bucket->get_key("non-existing-key"));
die $bucket->errstr if $bucket->err;

# fetch a key's metadata
$val = $bucket->head_key("key");
is( $val->{value},               '' );
is( $val->{content_type},        'text/html' );
is( $val->{etag},                'b9ece18c950afbfa6b0fdbfa4ff731d3' );
is( $val->{'x-amz-meta-colour'}, 'orange' );

# delete a key
ok($bucket->delete_key($key_name));
ok(! $bucket->delete_key("non-exist-key"));

# delete the entire bucket (Amazon requires it first be empty)
$bucket->delete_bucket;

DESCRIPTION

This module represents an S3 bucket. You get a bucket object from the AnyEvent::Net::Amazon::S3 object.

This module provides the same interface as Net::Amazon::S3::Bucket. In addition, some asynchronous methods returning AnyEvent condition variable are added.

METHODS

All Net::Amazon::S3::Bucket methods are available. In addition, there are the following asynchronous methods. Arguments of the methods are identical as original but return value becomes AnyEvent condition variable. You can get actual return value by calling shift->recv().

add_key_async
add_key_filename_async
copy_key_async
edit_metadata_async
head_key_async
get_key_async
get_key_filename_async
delete_key_async
delete_bucket_async
list_async
list_all_async
get_acl_async
set_acl_async
get_location_constraint_async

SEE ALSO

AUTHOR

Yasutaka ATARASHI <yakex@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Yasutaka ATARASHI.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.