Amazon S3

Amazon Simple Storage Service (http://aws.amazon.com/s3)

Version

2008.12.16

Copyright

2006-2008 LifeNexus Digital, Inc., and contributors.

License

Simplified BSD Licensehttp://opensource.org/licenses/bsd-license.php

See Also

Tarzanhttp://tarzan-aws.com
Amazon S3http://aws.amazon.com/s3

Constants

S3_LOCATION_US

Specify the US location.

S3_LOCATION_EU

Specify the European Union (EU) location.

S3_ACL_PRIVATE

ACL: Owner-only read/write.

S3_ACL_PUBLIC

ACL: Owner read/write, public read.

S3_ACL_OPEN

ACL: Public read/write.

S3_ACL_AUTH_READ

ACL: Owner read/write, authenticated read.

S3_GRANT_READ

When applied to a bucket, grants permission to list the bucket.  When applied to an object, this grants permission to read the object data and/or metadata.

S3_GRANT_WRITE

When applied to a bucket, grants permission to create, overwrite, and delete any object in the bucket.  This permission is not supported for objects.

S3_GRANT_READ_ACP

Grants permission to read the ACL for the applicable bucket or object.  The owner of a bucket or object always has this permission implicitly.

S3_GRANT_WRITE_ACP

Gives permission to overwrite the ACP for the applicable bucket or object.  The owner of a bucket or object always has this permission implicitly.  Granting this permission is equivalent to granting FULL_CONTROL because the grant recipient can make any changes to the ACP.

S3_GRANT_FULL_CONTROL

Provides READ, WRITE, READ_ACP, and WRITE_ACP permissions.  It does not convey additional rights and is provided only for convenience.

S3_USERS_AUTH

The “AuthenticatedUsers” group for access control policies.

S3_USERS_ALL

The “AllUsers” group for access control policies.

S3_USERS_LOGGING

The “LogDelivery” group for access control policies.

S3_PCRE_ALL

PCRE: Match all items

AmazonS3

Container for all Amazon S3-related methods.  Inherits additional methods from TarzanCore.

Extends

TarzanCore

Example Usage

require_once('tarzan.class.php');

// Instantiate a new AmazonS3 object using the settings from the config.inc.php file.
$s3 = new AmazonS3();

// Instantiate a new AmazonS3 object using these specific settings.
$s3 = new AmazonS3($key, $secret_key);

Properties

request_url

The request URL.

vhost

The virtual host setting.

base_acp_xml

The base XML elements to use for access control policy methods.

base_logging_xml

The base XML elements to use for logging methods.

Functions

__construct()

public function __construct($key =  null,
$secret_key =  null)

The constructor

Access

public

Parameters

keystring (Optional) Your Amazon API Key.  If blank, it will look for the AWS_KEY constant.
secret_keystring (Optional) Your Amazon API Secret Key.  If blank, it will look for the AWS_SECRET_KEY constant.

Returns

boolean false if no valid values are set, otherwise true.

authenticate()

public function authenticate($bucket,  
$opt =  null,
$location =  null,
$redirects =  0)

Authenticates a connection to S3.  This should not be used directly unless you’re writing custom methods for this class.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
optarray (Optional) Associative array of parameters for authenticating.  See the individual methods for allowed keys.
locationstring (Do Not Use) Used internally by this function on occasions when S3 returns a redirect code and it needs to call itself recursively.
redirectsinteger (Do Not Use) Used internally by this function on occasions when S3 returns a redirect code and it needs to call itself recursively.

Returns

TarzanHTTPResponse object

See Also

http://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTAuthentication.html

set_vhost()

public function set_vhost($vhost)

Use this virtual host instead of the normal bucket.s3.amazonaws.com domain.

Access

public

Parameters

vhoststring (Required) The hostname to use instead of bucket.s3.amazonaws.com.

Returns

void

See Also

Virtual Hosting of Bucketshttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/VirtualHosting.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/set_vhost.phps

create_bucket()

public function create_bucket($bucket,  
$locale =  null,
$returnCurlHandle =  null)

The bucket holds all of your objects, and provides a globally unique namespace in which you can manage the keys that identify objects.  A bucket can hold any number of objects.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
localestring (Optional) Sets the preferred geographical location for the bucket.  Accepts S3_LOCATION_US or S3_LOCATION_EU.  Defaults to S3_LOCATION_US.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTBucketPUT.html
Using Bucketshttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/UsingBucket.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/create_bucket.phps
Relatedget_bucket(), head_bucket(), delete_bucket()

get_bucket()

public function get_bucket($bucket,  
$opt =  null)

Referred to as “GET Bucket” in the AWS docs, but implemented here as AmazonS3::list_objects().  Therefore, this is an alias of list_objects().

See Also

Relatedcreate_bucket(), head_bucket(), delete_bucket(), list_objects()

get_bucket_locale()

public function get_bucket_locale($bucket,  
$returnCurlHandle =  null)

Lists the location constraint of the bucket.  U.S.-based buckets have no response.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTBucketLocationGET.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/get_bucket_locale.phps

head_bucket()

public function head_bucket($bucket,  
$returnCurlHandle =  null)

Reads only the HTTP headers of a bucket.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTObjectHEAD.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/head_bucket.phps
Relatedcreate_bucket(), get_bucket(), delete_bucket()

if_bucket_exists()

public function if_bucket_exists($bucket)

Checks whether this bucket already exists in your account or not.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.

Returns

boolean Whether the bucket exists or not.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/s3/if_bucket_exists.phps

delete_bucket()

public function delete_bucket($bucket,  
$force =  false,
$returnCurlHandle =  null)

Deletes a bucket from your account.  All objects in the bucket must be deleted before the bucket itself can be deleted.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
forceboolean (Optional) Whether to force-delete the bucket and all of its contents.  Defaults to false.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object if normal bucket deletion or if forced bucket deletion was successful, a boolean false if the forced deletion was unsuccessful.

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTBucketDELETE.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/delete_bucket.phps
Relatedcreate_bucket(), get_bucket(), head_bucket()

copy_bucket()

public function copy_bucket($source_bucket,  
$dest_bucket,  
$acl =  S3_ACL_PRIVATE)

Copies the contents of a bucket into a new bucket.

Access

public

Parameters

source_bucketstring (Required) The name of the source bucket.
dest_bucketstring (Required) The name of the destination bucket.
aclstring (Optional) One of the following options: S3_ACL_PRIVATE, S3_ACL_PUBLIC, S3_ACL_OPEN, or S3_ACL_AUTH_READ.  Defaults to S3_ACL_PRIVATE.

Returns

TarzanHTTPResponse object

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/s3/copy_bucket.phps
Relatedcopy_object(), rename_bucket(), list_buckets()

rename_bucket()

public function rename_bucket($source_bucket,
$dest_bucket)

Renames a bucket by making a copy and deleting the original.

Access

public

Parameters

source_bucketstring (Required) The name of the source bucket.
dest_bucketstring (Required) The name of the destination bucket.

Returns

TarzanHTTPResponse object

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/s3/rename_bucket.phps
Relatedrename_object(), copy_bucket(), list_buckets()

get_bucket_size()

public function get_bucket_size($bucket)

Gets the number of files in the bucket.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.

Returns

integer The number of files in the bucket.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/s3/get_bucket_size.phps
Relatedget_bucket_filesize()

get_bucket_filesize()

public function get_bucket_filesize($bucket,  
$friendly_format =  false)

Gets the file size of the contents of the bucket.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
friendly_formatboolean (Optional) Whether to format the value to 2 decimal points using the largest possible unit (i.e.  3.42 GB).

Returns

integer | string The number of bytes as an integer, or the friendly format as a string.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/s3/get_bucket_filesize.phps
Relatedget_bucket_size(), get_object_filesize()

list_buckets()

public function list_buckets($returnCurlHandle =  null)

Gets a list of all of the buckets on the S3 account.

Access

public

Parameters

returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTServiceGET.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/list_buckets.phps
Relatedget_bucket_list()

get_bucket_list()

public function get_bucket_list($pcre =  null)

ONLY lists the bucket names, as an array, on the S3 account.

Access

public

Parameters

pcrestring (Optional) A Perl-Compatible Regular Expression (PCRE) to filter the names against.

Returns

array The list of matching bucket names.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/s3/get_bucket_list.phps
Relatedlist_buckets()

get_bucket_acl()

public function get_bucket_acl($bucket,  
$returnCurlHandle =  null)

Gets the ACL settings for a bucket.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTAccessPolicy.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/get_bucket_acl.phps
Relatedset_object_acl(), set_bucket_acl(), get_object_acl()

set_bucket_acl()

public function set_bucket_acl($bucket,  
$acl =  S3_ACL_PRIVATE,
$returnCurlHandle =  null)

Sets the ACL settings for a bucket.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
aclstring (Optional) One of the following options: S3_ACL_PRIVATE, S3_ACL_PUBLIC, S3_ACL_OPEN, or S3_ACL_AUTH_READ.  Alternatively, an array of associative arrays.  Each associative array contains an ‘id’ and a ‘permission’.  Defaults to S3_ACL_PRIVATE.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTAccessPolicy.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/set_bucket_acl.phps
Relatedset_object_acl(), get_bucket_acl(), get_object_acl()

create_object()

public function create_object($bucket,  
$opt =  null)

Once you have a bucket, you can start storing objects in it.  Objects are stored using the HTTP PUT method.  Each object can hold up to 5 GB of data.  When you store an object, S3 streams the data to multiple storage servers in multiple data centers to ensure that the data remains available in the event of internal network or hardware failure.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
optarray (Required) Associative array of parameters which can have the following keys:

Keys for the $opt parameter

filenamestring (Required) The filename for the object.
bodystring (Required) The data to be stored in the object.
contentTypestring (Required) The type of content that is being sent in the body.
aclstring (Optional) One of the following options: S3_ACL_PRIVATE, S3_ACL_PUBLIC, S3_ACL_OPEN, or S3_ACL_AUTH_READ.  Defaults to S3_ACL_PRIVATE.
metaarray (Optional) Associative array of key-value pairs.  Represented by x-amz-meta-: Any header starting with this prefix is considered user metadata.  It will be stored with the object and returned when you retrieve the object.  The total size of the HTTP request, not including the body, must be less than 4 KB.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTObjectPUT.html
ACL Policyhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTAccessPolicy.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/create_object.phps
Relatedget_object(), head_object(), delete_object()

get_object()

public function get_object($bucket,  
$filename,  
$opt =  null)

Reads the contents of an object within a bucket.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
optarray (Required) Associative array of parameters which can have the following keys:

Keys for the $opt parameter

lastmodifiedstring (Optional) The LastModified header passed in from a previous request.  If used, requires ‘etag’ as well.  Will return a 304 if file hasn’t changed.
etagstring (Optional) The ETag header passed in from a previous request.  If used, requires ‘lastmodified’ as well.  Will return a 304 if file hasn’t changed.
rangestring (Optional) A range of bytes to fetch from the file.  Useful for downloading partial bits or completing incomplete files.  Range notated with a hyphen (e.g.  0-10485759).  Defaults to the complete file.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTObjectGET.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/get_object.phps
Relatedcreate_object(), head_object(), delete_object()

head_object()

public function head_object($bucket,  
$filename,  
$returnCurlHandle =  null)

Reads only the HTTP headers of an object within a bucket.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
filenamestring (Required) The filename for the object.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTObjectHEAD.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/head_object.phps
Relatedcreate_object(), get_object(), delete_object(), if_object_exists()

if_object_exists()

public function if_object_exists($bucket,
$filename)

Checks whether this object already exists in this bucket.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
filenamestring (Required) The filename for the object.

Returns

boolean Whether the object exists or not.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/s3/if_object_exists.phps
Relatedhead_object()

delete_object()

public function delete_object($bucket,  
$filename,  
$returnCurlHandle =  null)

Deletes an object from within a bucket.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
filenamestring (Required) The filename for the object.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTObjectDELETE.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/delete_object.phps
Relatedcreate_object(), get_object(), head_object(), delete_all_objects()

delete_all_objects()

public function delete_all_objects($bucket,  
$pcre =  S3_PCRE_ALL)

Delete all of the objects inside the specified bucket.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
pcrestring (Optional) A Perl-Compatible Regular Expression (PCRE) to filter the names against.  Defaults to S3_PCRE_ALL.

Returns

boolean Determines the success of deleting all files.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/s3/delete_all_objects.phps
Relateddelete_object()

list_objects()

public function list_objects($bucket,  
$opt =  null)

Lists the objects in a bucket.  Provided as the ‘GetBucket’ action in Amazon’s REST API.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
optarray (Required) Associative array of parameters which can have the following keys:

Keys for the $opt parameter

prefixstring (Optional) Restricts the response to only contain results that begin with the specified prefix.
markerstring (Optional) It restricts the response to only contain results that occur alphabetically after the value of marker.
maxKeysstring (Optional) Limits the number of results returned in response to your query.  Will return no more than this number of results, but possibly less.
delimiterstring (Optional) Unicode string parameter.  Keys that contain the same string between the prefix and the first occurrence of the delimiter will be rolled up into a single result element in the CommonPrefixes collection.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTBucketGET.html
List Keyshttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/ListingKeysRequest.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/list_objects.phps
Relatedget_bucket(), get_object_list()

get_object_filesize()

public function get_object_filesize($bucket,  
$filename,  
$friendly_format =  false)

Gets the file size of the object.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
filenamestring (Required) The filename for the object.
friendly_formatboolean (Optional) Whether to format the value to 2 decimal points using the largest possible unit (i.e.  3.42 GB).

Returns

integer | string The number of bytes as an integer, or the friendly format as a string.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/s3/get_object_filesize.phps
Relatedget_bucket_filesize()

get_object_list()

public function get_object_list($bucket,  
$opt =  null)

ONLY lists the object filenames from a bucket.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
optarray (Required) Associative array of parameters which can have the following keys:

Keys for the $opt parameter

prefixstring (Optional) Restricts the response to only contain results that begin with the specified prefix.
markerstring (Optional) It restricts the response to only contain results that occur alphabetically after the value of marker.
maxKeysstring (Optional) Limits the number of results returned in response to your query.  Will return no more than this number of results, but possibly less.
delimiterstring (Optional) Unicode string parameter.  Keys that contain the same string between the prefix and the first occurrence of the delimiter will be rolled up into a single result element in the CommonPrefixes collection.
pcrestring (Optional) A Perl-Compatible Regular Expression (PCRE) to filter the names against.  This is applied AFTER any native S3 filtering from ‘prefix’, ‘marker’, ‘maxKeys’, or ‘delimiter’.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

array The list of matching object names.

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/ListingKeysRequest.html
List Keyshttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/gsg/ListKeys.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/get_object_list.phps
Relatedget_bucket_list(), list_objects()

copy_object()

public function copy_object($source_bucket,  
$source_filename,  
$dest_bucket,  
$dest_filename,  
$opt =  null)

Copies an object to a new location, whether in the same locale/bucket or otherwise.

Access

public

Parameters

source_bucketstring (Required) The name of the bucket that contains the source file.
source_filenamestring (Required) The source filename that you want to copy.
dest_bucketstring (Required) The name of the bucket that you want to copy the file to.
dest_filenamestring (Required) The filename that you want to give to the copy.
optarray (Required) Associative array of parameters which can have the following keys:

Keys for the $opt parameter

aclstring (Optional) One of the following options: S3_ACL_PRIVATE, S3_ACL_PUBLIC, S3_ACL_OPEN, or S3_ACL_AUTH_READ.  Defaults to S3_ACL_PRIVATE.
metaarray (Optional) Associative array of key-value pairs.  Represented by x-amz-meta-: Any header starting with this prefix is considered user metadata.  It will be stored with the object and returned when you retrieve the object.  The total size of the HTTP request, not including the body, must be less than 4 KB.
metadataDirectivestring (Optional) Accepts either COPY or REPLACE.  You will likely never need to use this, as it manages itself with no issues.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTObjectCOPY.html
Using and Copying Objectshttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/UsingCopyingObjects.html
PUT Request Headershttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTObjectPUT.html#RESTObjectPUTRequestHeaders
Example Usagehttp://tarzan-aws.com/docs/examples/s3/copy_object.phps
Relatedcopy_bucket(), duplicate_object(), move_object(), rename_object()

duplicate_object()

public function duplicate_object($bucket,  
$source_filename,  
$dest_filename,  
$acl =  S3_ACL_PRIVATE)

Identical to copy_object(), except that it only copies within a single bucket.

Access

public

Parameters

bucketstring (Required) The name of the bucket that contains the file.
source_filenamestring (Required) The source filename that you want to copy.
dest_filenamestring (Required) The filename that you want to give to the copy.
aclstring (Optional) One of the following options: S3_ACL_PRIVATE, S3_ACL_PUBLIC, S3_ACL_OPEN, or S3_ACL_AUTH_READ.  Defaults to S3_ACL_PRIVATE.

Returns

TarzanHTTPResponse object

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/s3/duplicate_object.phps
Relatedcopy_object(), move_object(), rename_object()

move_object()

public function move_object($source_bucket,  
$source_filename,  
$dest_bucket,  
$dest_filename,  
$acl =  S3_ACL_PRIVATE)

Moves an object to a new location, whether in the same locale/bucket or otherwise.

Access

public

Parameters

source_bucketstring (Required) The name of the bucket that contains the source file.
source_filenamestring (Required) The source filename that you want to copy.
dest_bucketstring (Required) The name of the bucket that you want to copy the file to.
dest_filenamestring (Required) The filename that you want to give to the copy.
aclstring (Optional) One of the following options: S3_ACL_PRIVATE, S3_ACL_PUBLIC, S3_ACL_OPEN, or S3_ACL_AUTH_READ.  Defaults to S3_ACL_PRIVATE.

Returns

array TarzanHTTPResponse objects for the copy and the delete.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/s3/move_object.phps
Relatedcopy_object(), duplicate_object(), rename_object()

rename_object()

public function rename_object($bucket,  
$source_filename,  
$dest_filename,  
$acl =  S3_ACL_PRIVATE)

Identical to move_object(), except that it only moves within a single bucket.

Access

public

Parameters

bucketstring (Required) The name of the bucket that contains the file.
source_filenamestring (Required) The source filename that you want to copy.
dest_filenamestring (Required) The filename that you want to give to the copy.
aclstring (Optional) One of the following options: S3_ACL_PRIVATE, S3_ACL_PUBLIC, S3_ACL_OPEN, or S3_ACL_AUTH_READ.  Defaults to S3_ACL_PRIVATE.

Returns

TarzanHTTPResponse object

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/s3/rename_object.phps
Relatedcopy_object(), duplicate_object(), move_object()

get_object_acl()

public function get_object_acl($bucket,  
$filename,  
$returnCurlHandle =  null)

Gets the ACL settings for a object.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
filenamestring (Required) The filename for the object.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTAccessPolicy.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/get_object_acl.phps
Relatedset_object_acl(), set_bucket_acl(), get_bucket_acl()

set_object_acl()

public function set_object_acl($bucket,  
$filename,  
$acl =  S3_ACL_PRIVATE,
$returnCurlHandle =  null)

Sets the ACL settings for a object.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
filenamestring (Required) The filename for the object.
aclstring (Optional) One of the following options: S3_ACL_PRIVATE, S3_ACL_PUBLIC, S3_ACL_OPEN, or S3_ACL_AUTH_READ.  Alternatively, an array of associative arrays.  Each associative array contains an ‘id’ and a ‘permission’.  Defaults to S3_ACL_PRIVATE.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTAccessPolicy.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/set_object_acl.phps
Relatedset_bucket_acl(), get_bucket_acl(), get_object_acl()

get_logs()

public function get_logs($bucket)

Get the access logs associated with a given bucket.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.  Pass null if using set_vhost().

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/ServerLogs.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/logging.phps
Relatedget_logs(), enable_logging(), disable_logging()

enable_logging()

public function enable_logging($bucket,  
$target_bucket,  
$target_prefix,  
$users =  null)

Enable access logging.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be log.  Pass null if using set_vhost().
target_bucketstring (Required) The name of the bucket to store the logs in.
target_prefixstring (Required) The prefix to give to the log filenames.
usersarray (Optional) Any non-owner users to give access to.  Set as an array of key-value pairs: the email address (must be tied to an AWS account) is the key, and the permission is the value.  Allowable permissions are S3_GRANT_READ, S3_GRANT_WRITE, S3_GRANT_READ_ACP, S3_GRANT_WRITE_ACP, and S3_GRANT_FULL_CONTROL.

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/LoggingAPI.html
Permissionshttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/S3_ACLs.html#S3_ACLs_Permissions
Example Usagehttp://tarzan-aws.com/docs/examples/s3/logging.phps
Relatedget_logs(), enable_logging(), disable_logging()

disable_logging()

public function disable_logging($bucket)

Disable access logging.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.  Pass null if using set_vhost().

Returns

TarzanHTTPResponse object

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/LoggingAPI.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/logging.phps
Relatedget_logs(), enable_logging(), disable_logging()

store_remote_file()

public function store_remote_file($remote_file,  
$bucket,  
$filename,  
$opt =  null)

Takes an existing remote file, stores it to S3, and returns a URL.

Access

public

Parameters

remote_filestring (Required) The full URL of the file to store on the S3 service.
bucketstring (Required) The name of the bucket to be used.
filenamestring (Required) The filename for the object.
optarray (Required) Associative array of parameters which can have the following keys:

Keys for the $opt parameter

aclstring (Optional) One of the following options: S3_ACL_PRIVATE, S3_ACL_PUBLIC, S3_ACL_OPEN, or S3_ACL_AUTH_READ.  Defaults to S3_ACL_PRIVATE.
overwriteboolean (Optional) If set to true, checks to see if the file exists and will overwrite the old data with new data.  Defaults to false.

Returns

string The S3 URL for the uploaded file.  Returns null if unsuccessful.

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/s3/store_remote_file.phps

change_content_type()

public function change_content_type($bucket,  
$filename,  
$contentType,  
$returnCurlHandle =  null)

Changes the content type for an existing object.

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
filenamestring (Required) The filename for the object.
contentTypestring (Required) The content-type to apply to the object.
returnCurlHandleboolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request.  This is useful for MultiCURL requests.

Returns

TarzanHTTPResponse object

See Also

Example Usagehttp://tarzan-aws.com/docs/examples/s3/change_content_type.phps

get_object_url()

public function get_object_url($bucket,  
$filename,  
$qsa =  0,
$torrent =  false)

Gets the web-accessible URL for the file (assuming you’ve set the ACL settings to S3_ACL_PUBLIC).

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
filenamestring (Required) The filename for the object.
qsainteger (Optional) How many seconds should the query string authenticated URL work for?  Only generates query string authentication parameters if value is greater than 0.  Defaults to 0.
torrentboolean (Optional) Whether to return the torrent version of the URL or not.  Defaults to false.

Returns

string The file URL (with authentication and/or torrent parameters if requested).

See Also

Query String Authenticationhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/S3_QSAuth.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/get_object_url.phps
Relatedget_torrent_url()

get_torrent_url()

public function get_torrent_url($bucket,  
$filename,  
$qsa =  0)

Gets the web-accessible torrent URL for the file (assuming you’ve set the ACL settings to S3_ACL_PUBLIC).

Access

public

Parameters

bucketstring (Required) The name of the bucket to be used.
filenamestring (Required) The filename for the object.
qsainteger (Optional) How many seconds should the query string authenticated URL work for?  Only generates query string authentication parameters if value is greater than 0.  Defaults to 0.

Returns

string The torrent URL (with authentication parameters if requested).

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/index.html?S3TorrentRetrieve.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/get_torrent_url.phps
Relatedget_object_url()

generate_access_policy()

public function generate_access_policy($canonical_id,
$canonical_name,
$users)

Generate the XML to be used for the Access Control Policy.

Access

public

Parameters

canonical_idstring (Required) The Canonical ID for the Owner.  Use the AWS_CANONICAL_ID constant or the ‘id’ value from get_canonical_user_id().
canonical_namestring (Required) The Canonical Display Name for the Owner.  Use the AWS_CANONICAL_NAME constant or the ‘display_name’ value from get_canonical_user_id().
usersarray (Optional) Array of associative arrays.  Each associative array contains an ‘id’ and a ‘permission’.

Returns

string Access Control Policy XML.

See Also

AWS Methodhttp://docs.amazonwebservices.com/AmazonS3/2006-03-01/S3_ACLs.html
Example Usagehttp://tarzan-aws.com/docs/examples/s3/generate_access_policy.phps

get_canonical_user_id()

public function get_canonical_user_id()

Obtains the CanonicalUser ID and DisplayName from the server.

Access

public

Returns

array The id and display_name values.