Amazon::S3::Bucket(3pm) | User Contributed Perl Documentation | Amazon::S3::Bucket(3pm) |
Amazon::S3::Bucket - A container class for a S3 bucket and its contents.
use Amazon::S3; # creates bucket object (no "bucket exists" check) my $bucket = $s3->bucket("foo"); # create resource with meta data (attributes) my $keyname = 'testing.txt'; my $value = 'T'; $bucket->add_key( $keyname, $value, { content_type => 'text/plain', 'x-amz-meta-colour' => 'orange', } ); # list keys in the bucket $response = $bucket->list or die $s3->err . ": " . $s3->errstr; print $response->{bucket}."\n"; for my $key (@{ $response->{keys} }) { print "\t".$key->{key}."\n"; } # check if resource exists. print "$keyname exists\n" if $bucket->head_key($keyname); # delete key from bucket $bucket->delete_key($keyname);
Instaniates a new bucket object.
Requires a hash containing two arguments:
NOTE: This method does not check if a bucket actually exists. It simply instaniates the bucket.
Typically a developer will not call this method directly, but work through the interface in S3::Amazon that will handle their creation.
Takes three positional parameters:
In addition to additional and overridden HTTP headers, this HASHREF can have a "acl_short" key to set the permissions (access) of the resource without a separate call via "add_acl" or in the form of an XML document. See the documentation in "add_acl" for the values and usage.
Returns a boolean indicating its success. Check "err" and "errstr" for error message if this operation fails.
The method works like "add_key" except the value is assumed to be a filename on the local file system. The file will be streamed rather then loaded into memory in one big chunk.
Returns a configuration HASH of the given key. If a key does not exist in the bucket "undef" will be returned.
Takes a key and an optional HTTP method and fetches it from S3. The default HTTP method is GET.
The method returns "undef" if the key does not exist in the bucket and throws an exception (dies) on server errors.
On success, the method returns a HASHREF containing:
This method works like "get_key", but takes an added filename that the S3 resource will be written to.
Permanently removes $key_name from the bucket. Returns a boolean value indicating the operations success.
Permanently removes the bucket from the server. A bucket cannot be removed if it contains any keys (contents).
This is an alias for "$s3-"delete_bucket($bucket)>.
List all keys in this bucket.
See "list_bucket" in Amazon::S3 for documentation of this method.
List all keys in this bucket without having to worry about 'marker'. This may make multiple requests to S3 under the hood.
See "list_bucket_all" in Amazon::S3 for documentation of this method.
Retrieves the Access Control List (ACL) for the bucket or resource as an XML document.
Retrieves the Access Control List (ACL) for the bucket or resource. Requires a HASHREF argument with one of the following keys:
According to the Amazon S3 API documentation the following recognized acl_short types are defined as follows:
Returns a boolean indicating the operations success.
Returns the location constraint data on a bucket.
For more information on location constraints, refer to the Amazon S3 Developer Guide.
The S3 error code for the last error the account encountered.
A human readable error string for the last error the account encountered.
Amazon::S3
Please see the Amazon::S3 manpage for author, copyright, and license information.
2018-08-17 | perl v5.26.2 |