Zend Framework  1.12
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Zend_Service_Amazon_S3 Class Reference

Public Member Functions

 setEndpoint ($endpoint)
 Set S3 endpoint to use.
 
 getEndpoint ()
 Get current S3 endpoint.
 
 __construct ($accessKey=null, $secretKey=null, $region=null)
 Constructor.
 
 _validBucketName ($bucket)
 Verify if the bucket name is valid.
 
 createBucket ($bucket, $location=null)
 Add a new bucket.
 
 isBucketAvailable ($bucket)
 Checks if a given bucket name is available.
 
 isObjectAvailable ($object)
 Checks if a given object exists.
 
 removeBucket ($bucket)
 Remove a given bucket.
 
 getInfo ($object)
 Get metadata information for a given object.
 
 getBuckets ()
 List the S3 buckets.
 
 cleanBucket ($bucket)
 Remove all objects in the bucket.
 
 getObjectsByBucket ($bucket, $params=array())
 List the objects in a bucket.
 
 getObjectsAndPrefixesByBucket ($bucket, $params=array())
 List the objects and common prefixes in a bucket.
 
 getObject ($object, $paidobject=false)
 Get an object.
 
 getObjectStream ($object, $streamfile=null, $paidobject=false)
 Get an object using streaming.
 
 putObject ($object, $data, $meta=null)
 Upload an object by a PHP string.
 
 putFile ($path, $object, $meta=null)
 Put file to S3 as object.
 
 putFileStream ($path, $object, $meta=null)
 Put file to S3 as object, using streaming.
 
 removeObject ($object)
 Remove a given object.
 
 copyObject ($sourceObject, $destObject, $meta=null)
 Copy an object.
 
 moveObject ($sourceObject, $destObject, $meta=null)
 Move an object.
 
 _makeRequest ($method, $path='', $params=null, $headers=array(), $data=null)
 Make a request to Amazon S3.
 
 registerAsClient ($name)
 Register this object as stream wrapper client.
 
 unregisterAsClient ($name)
 Unregister this object as stream wrapper client.
 
 registerStreamWrapper ($name='s3')
 Register this object as stream wrapper.
 
 unregisterStreamWrapper ($name='s3')
 Unregister this object as stream wrapper.
 
- Public Member Functions inherited from Zend_Service_Amazon_Abstract
 __construct ($accessKey=null, $secretKey=null)
 Create Amazon client.
 

Static Public Member Functions

static getMimeType ($path)
 Attempt to get the content-type of a file based on the extension.
 
static getWrapperClient ($name)
 Get wrapper client for stream type.
 
- Static Public Member Functions inherited from Zend_Service_Amazon_Abstract
static setKeys ($accessKey, $secretKey)
 Set the keys to use when accessing SQS.
 
- Static Public Member Functions inherited from Zend_Service_Abstract
static setHttpClient (Zend_Http_Client $httpClient)
 Sets the HTTP client object to use for retrieving the feeds.
 
static getHttpClient ()
 Gets the HTTP client object.
 

Public Attributes

const S3_ENDPOINT = 's3.amazonaws.com'
 
const S3_ACL_PRIVATE = 'private'
 
const S3_ACL_PUBLIC_READ = 'public-read'
 
const S3_ACL_PUBLIC_WRITE = 'public-read-write'
 
const S3_ACL_AUTH_READ = 'authenticated-read'
 
const S3_REQUESTPAY_HEADER = 'x-amz-request-payer'
 
const S3_ACL_HEADER = 'x-amz-acl'
 
const S3_CONTENT_TYPE_HEADER = 'Content-Type'
 

Protected Member Functions

 _fixupObjectName ($object)
 Make sure the object name is valid.
 
 addSignature ($method, $path, &$headers)
 Add the S3 Authorization signature to the request headers.
 
- Protected Member Functions inherited from Zend_Service_Amazon_Abstract
 _getAccessKey ()
 Method to fetch the Access Key.
 
 _getSecretKey ()
 Method to fetch the Secret AWS Key.
 

Protected Attributes

 $_endpoint
 
- Protected Attributes inherited from Zend_Service_Amazon_Abstract
 $_secretKey
 
 $_accessKey
 

Static Protected Attributes

static $_wrapperClients = array()
 
- Static Protected Attributes inherited from Zend_Service_Amazon_Abstract
static $_defaultAccessKey = null
 
static $_defaultSecretKey = null
 
- Static Protected Attributes inherited from Zend_Service_Abstract
static $_httpClient = null
 

Constructor & Destructor Documentation

__construct (   $accessKey = null,
  $secretKey = null,
  $region = null 
)

Constructor.

Parameters
string$accessKey
string$secretKey
string$region

Member Function Documentation

_fixupObjectName (   $object)
protected

Make sure the object name is valid.

Parameters
string$object
Returns
string
_makeRequest (   $method,
  $path = '',
  $params = null,
  $headers = array(),
  $data = null 
)

Make a request to Amazon S3.

Parameters
string$methodRequest method
string$pathPath to requested object
array$paramsRequest parameters
array$headersHTTP headers
string | resource$dataRequest data
Returns
Zend_Http_Response
See Also
Zend_Service_Amazon_S3_Exception
_validBucketName (   $bucket)

Verify if the bucket name is valid.

Parameters
string$bucket
Returns
boolean
See Also
Zend_Service_Amazon_S3_Exception
Zend_Service_Amazon_S3_Exception
Zend_Service_Amazon_S3_Exception
addSignature (   $method,
  $path,
$headers 
)
protected

Add the S3 Authorization signature to the request headers.

Parameters
string$method
string$path
array&$headers
Returns
string
cleanBucket (   $bucket)

Remove all objects in the bucket.

Parameters
string$bucket
Returns
boolean
copyObject (   $sourceObject,
  $destObject,
  $meta = null 
)

Copy an object.

Parameters
string$sourceObjectSource object name
string$destObjectDestination object name
array$meta(OPTIONAL) Metadata to apply to desination object. Set to null to copy metadata from source object.
Returns
boolean
createBucket (   $bucket,
  $location = null 
)

Add a new bucket.

Parameters
string$bucket
Returns
boolean
getBuckets ( )

List the S3 buckets.

Returns
array|false
getEndpoint ( )

Get current S3 endpoint.

Returns
Zend_Uri_Http
getInfo (   $object)

Get metadata information for a given object.

Parameters
string$object
Returns
array|false
static getMimeType (   $path)
static

Attempt to get the content-type of a file based on the extension.

Parameters
string$path
Returns
string
getObject (   $object,
  $paidobject = false 
)

Get an object.

Parameters
string$object
bool$paidobjectThis is "requestor pays" object
Returns
string|false
getObjectsAndPrefixesByBucket (   $bucket,
  $params = array() 
)

List the objects and common prefixes in a bucket.

Provides the list of object keys and common prefixes that are contained in the bucket. Valid params include the following. prefix - Limits the response to keys which begin with the indicated prefix. You can use prefixes to separate a bucket into different sets of keys in a way similar to how a file system uses folders. marker - Indicates where in the bucket to begin listing. The list will only include keys that occur lexicographically after marker. This is convenient for pagination: To get the next page of results use the last key of the current page as the marker. max-keys - The maximum number of keys you'd like to see in the response body. The server might return fewer than this many keys, but will not return more. delimiter - Causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be rolled up into a single result element in the CommonPrefixes collection. These rolled-up keys are not returned elsewhere in the response.

See Also
ZF-11401
Parameters
string$bucket
array$paramsS3 GET Bucket Paramater
Returns
array|false
getObjectsByBucket (   $bucket,
  $params = array() 
)

List the objects in a bucket.

Provides the list of object keys that are contained in the bucket. Valid params include the following. prefix - Limits the response to keys which begin with the indicated prefix. You can use prefixes to separate a bucket into different sets of keys in a way similar to how a file system uses folders. marker - Indicates where in the bucket to begin listing. The list will only include keys that occur lexicographically after marker. This is convenient for pagination: To get the next page of results use the last key of the current page as the marker. max-keys - The maximum number of keys you'd like to see in the response body. The server might return fewer than this many keys, but will not return more. delimiter - Causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be rolled up into a single result element in the CommonPrefixes collection. These rolled-up keys are not returned elsewhere in the response.

Parameters
string$bucket
array$paramsS3 GET Bucket Paramater
Returns
array|false
getObjectStream (   $object,
  $streamfile = null,
  $paidobject = false 
)

Get an object using streaming.

Can use either provided filename for storage or create a temp file if none provided.

Parameters
string$objectObject path
string$streamfileFile to write the stream to
bool$paidobjectThis is "requestor pays" object
Returns
Zend_Http_Response_Stream|false
static getWrapperClient (   $name)
static

Get wrapper client for stream type.

Parameters
string$name
Returns
Zend_Service_Amazon_S3
isBucketAvailable (   $bucket)

Checks if a given bucket name is available.

Parameters
string$bucket
Returns
boolean
isObjectAvailable (   $object)

Checks if a given object exists.

Parameters
string$object
Returns
boolean
moveObject (   $sourceObject,
  $destObject,
  $meta = null 
)

Move an object.

Performs a copy to dest + verify + remove source

Parameters
string$sourceObjectSource object name
string$destObjectDestination object name
array$meta(OPTIONAL) Metadata to apply to destination object. Set to null to retain existing metadata.
putFile (   $path,
  $object,
  $meta = null 
)

Put file to S3 as object.

Parameters
string$pathFile name
string$objectObject name
array$metaMetadata
Returns
boolean
See Also
Zend_Service_Amazon_S3_Exception
putFileStream (   $path,
  $object,
  $meta = null 
)

Put file to S3 as object, using streaming.

Parameters
string$pathFile name
string$objectObject name
array$metaMetadata
Returns
boolean
See Also
Zend_Service_Amazon_S3_Exception
putObject (   $object,
  $data,
  $meta = null 
)

Upload an object by a PHP string.

Parameters
string$objectObject name
string | resource$dataObject data (can be string or stream)
array$metaMetadata
Returns
boolean
registerAsClient (   $name)

Register this object as stream wrapper client.

Parameters
string$name
Returns
Zend_Service_Amazon_S3
registerStreamWrapper (   $name = 's3')

Register this object as stream wrapper.

Parameters
string$name
Returns
Zend_Service_Amazon_S3
See Also
Zend_Service_Amazon_S3_Stream
removeBucket (   $bucket)

Remove a given bucket.

All objects in the bucket must be removed prior to removing the bucket.

Parameters
string$bucket
Returns
boolean
removeObject (   $object)

Remove a given object.

Parameters
string$object
Returns
boolean
setEndpoint (   $endpoint)

Set S3 endpoint to use.

Parameters
string | Zend_Uri_Http$endpoint
Returns
Zend_Service_Amazon_S3
See Also
Zend_Service_Amazon_S3_Exception
unregisterAsClient (   $name)

Unregister this object as stream wrapper client.

Parameters
string$name
Returns
Zend_Service_Amazon_S3
unregisterStreamWrapper (   $name = 's3')

Unregister this object as stream wrapper.

Parameters
string$name
Returns
Zend_Service_Amazon_S3

Member Data Documentation

$_endpoint
protected
$_wrapperClients = array()
staticprotected
const S3_ACL_AUTH_READ = 'authenticated-read'
const S3_ACL_HEADER = 'x-amz-acl'
const S3_ACL_PRIVATE = 'private'
const S3_ACL_PUBLIC_READ = 'public-read'
const S3_ACL_PUBLIC_WRITE = 'public-read-write'
const S3_CONTENT_TYPE_HEADER = 'Content-Type'
const S3_ENDPOINT = 's3.amazonaws.com'
const S3_REQUESTPAY_HEADER = 'x-amz-request-payer'