Service/Amazon/S3.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Service
- Subpackage
- Amazon_S3
- Version
- $Id: S3.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Service_Amazon_S3
Amazon S3 PHP connection class
- Parent(s)
- \Zend_Service_Amazon_Abstract < \Zend_Service_Abstract
- See
- \global\http://docs.amazonwebservices.com/AmazonS3/2006-03-01/
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
Properties

string $_accessKey = - Type
- string
- Inherited_from
- \Zend_Service_Amazon_Abstract::$$_accessKey

string $_defaultAccessKey = nullnullDetails- Type
- string
- Inherited_from
- \Zend_Service_Amazon_Abstract::$$_defaultAccessKey

string $_defaultSecretKey = nullnullDetails- Type
- string
- Inherited_from
- \Zend_Service_Amazon_Abstract::$$_defaultSecretKey

\Zend_Http_Client $_httpClient = nullHTTP Client used to query all web services
Inherited from: \Zend_Service_Abstract::$$_httpClient\Zend_Service_Amazon_Abstract::$$_httpClientnullDetails- Type
- \Zend_Http_Client
- Inherited_from
- \Zend_Service_Abstract::$$_httpClient
- Inherited_from
- \Zend_Service_Amazon_Abstract::$$_httpClient

string $_secretKey = - Type
- string
- Inherited_from
- \Zend_Service_Amazon_Abstract::$$_secretKey
Methods

__construct(string $accessKey = null, string $secretKey = null, string $region = null) : voidConstructor
| Name | Type | Description |
|---|---|---|
| $accessKey | string | |
| $secretKey | string | |
| $region | string |

_fixupObjectName(string $object) : stringMake sure the object name is valid
| Name | Type | Description |
|---|---|---|
| $object | string |
| Type | Description |
|---|---|
| string |

_getAccessKey() : stringMethod to fetch the Access Key
Inherited from: \Zend_Service_Amazon_Abstract::_getAccessKey()| Type | Description |
|---|---|
| string |

_getSecretKey() : stringMethod to fetch the Secret AWS Key
Inherited from: \Zend_Service_Amazon_Abstract::_getSecretKey()| Type | Description |
|---|---|
| string |

_makeRequest(string $method, string $path = '', array $params = null, array $headers = array(), string | resource $data = null) : \Zend_Http_ResponseMake a request to Amazon S3
| Name | Type | Description |
|---|---|---|
| $method | string | Request method |
| $path | string | Path to requested object |
| $params | array | Request parameters |
| $headers | array | HTTP headers |
| $data | string | resource | Request data |
| Type | Description |
|---|---|
| \Zend_Http_Response |

_validBucketName(string $bucket) : booleanVerify if the bucket name is valid
| Name | Type | Description |
|---|---|---|
| $bucket | string |
| Type | Description |
|---|---|
| boolean |

addSignature(string $method, string $path, array $headers) : stringAdd the S3 Authorization signature to the request headers
| Name | Type | Description |
|---|---|---|
| $method | string | |
| $path | string | |
| $headers | array | &$headers |
| Type | Description |
|---|---|
| string |

cleanBucket(string $bucket) : booleanRemove all objects in the bucket.
| Name | Type | Description |
|---|---|---|
| $bucket | string |
| Type | Description |
|---|---|
| boolean |

copyObject(string $sourceObject, string $destObject, array $meta = null) : booleanCopy an object
| Name | Type | Description |
|---|---|---|
| $sourceObject | string | Source object name |
| $destObject | string | Destination object name |
| $meta | array | (OPTIONAL) Metadata to apply to desination object. Set to null to copy metadata from source object. |
| Type | Description |
|---|---|
| boolean |

createBucket(string $bucket, $location = null) : booleanAdd a new bucket
| Name | Type | Description |
|---|---|---|
| $bucket | string | |
| $location |
| Type | Description |
|---|---|
| boolean |

getHttpClient() : \Zend_Http_ClientGets the HTTP client object.
Inherited from: \Zend_Service_Abstract::getHttpClient()\Zend_Service_Amazon_Abstract::getHttpClient()| Type | Description |
|---|---|
| \Zend_Http_Client |

getInfo(string $object) : array | falseGet metadata information for a given object
| Name | Type | Description |
|---|---|---|
| $object | string |
| Type | Description |
|---|---|
| array | false |

getMimeType(string $path) : stringAttempt to get the content-type of a file based on the extension
| Name | Type | Description |
|---|---|---|
| $path | string |
| Type | Description |
|---|---|
| string |

getObject(string $object, bool $paidobject = false) : string | falseGet an object
| Name | Type | Description |
|---|---|---|
| $object | string | |
| $paidobject | bool | This is "requestor pays" object |
| Type | Description |
|---|---|
| string | false |

getObjectStream(string $object, string $streamfile = null, bool $paidobject = false) : \Zend_Http_Response_Stream | falseGet an object using streaming
Can use either provided filename for storage or create a temp file if none provided.
| Name | Type | Description |
|---|---|---|
| $object | string | Object path |
| $streamfile | string | File to write the stream to |
| $paidobject | bool | This is "requestor pays" object |
| Type | Description |
|---|---|
| \Zend_Http_Response_Stream | false |

getObjectsAndPrefixesByBucket(string $bucket, array $params = array()) : array | falseList 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.
| Name | Type | Description |
|---|---|---|
| $bucket | string | |
| $params | array | S3 GET Bucket Paramater |
| Type | Description |
|---|---|
| array | false |
- See
- \global\ZF-11401

getObjectsByBucket(string $bucket, array $params = array()) : array | falseList 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.
| Name | Type | Description |
|---|---|---|
| $bucket | string | |
| $params | array | S3 GET Bucket Paramater |
| Type | Description |
|---|---|
| array | false |

getWrapperClient(string $name) : \Zend_Service_Amazon_S3Get wrapper client for stream type
| Name | Type | Description |
|---|---|---|
| $name | string |
| Type | Description |
|---|---|
| \Zend_Service_Amazon_S3 |

isBucketAvailable(string $bucket) : booleanChecks if a given bucket name is available
| Name | Type | Description |
|---|---|---|
| $bucket | string |
| Type | Description |
|---|---|
| boolean |

isObjectAvailable(string $object) : booleanChecks if a given object exists
| Name | Type | Description |
|---|---|---|
| $object | string |
| Type | Description |
|---|---|
| boolean |

moveObject(string $sourceObject, string $destObject, array $meta = null) : voidMove an object
Performs a copy to dest + verify + remove source
| Name | Type | Description |
|---|---|---|
| $sourceObject | string | Source object name |
| $destObject | string | Destination object name |
| $meta | array | (OPTIONAL) Metadata to apply to destination object. Set to null to retain existing metadata. |

putFile(string $path, string $object, array $meta = null) : booleanPut file to S3 as object
| Name | Type | Description |
|---|---|---|
| $path | string | File name |
| $object | string | Object name |
| $meta | array | Metadata |
| Type | Description |
|---|---|
| boolean |

putFileStream(string $path, string $object, array $meta = null) : booleanPut file to S3 as object, using streaming
| Name | Type | Description |
|---|---|---|
| $path | string | File name |
| $object | string | Object name |
| $meta | array | Metadata |
| Type | Description |
|---|---|
| boolean |

putObject(string $object, string | resource $data, array $meta = null) : booleanUpload an object by a PHP string
| Name | Type | Description |
|---|---|---|
| $object | string | Object name |
| $data | string | resource | Object data (can be string or stream) |
| $meta | array | Metadata |
| Type | Description |
|---|---|
| boolean |

registerAsClient(string $name) : \Zend_Service_Amazon_S3Register this object as stream wrapper client
| Name | Type | Description |
|---|---|---|
| $name | string |
| Type | Description |
|---|---|
| \Zend_Service_Amazon_S3 |

registerStreamWrapper(string $name = 's3') : \Zend_Service_Amazon_S3Register this object as stream wrapper
| Name | Type | Description |
|---|---|---|
| $name | string |
| Type | Description |
|---|---|
| \Zend_Service_Amazon_S3 |

removeBucket(string $bucket) : booleanRemove a given bucket.
All objects in the bucket must be removed prior to removing the bucket.
| Name | Type | Description |
|---|---|---|
| $bucket | string |
| Type | Description |
|---|---|
| boolean |

removeObject(string $object) : booleanRemove a given object
| Name | Type | Description |
|---|---|---|
| $object | string |
| Type | Description |
|---|---|
| boolean |

setEndpoint(string | \Zend_Uri_Http $endpoint) : \Zend_Service_Amazon_S3Set S3 endpoint to use
| Name | Type | Description |
|---|---|---|
| $endpoint | string | \Zend_Uri_Http |
| Type | Description |
|---|---|
| \Zend_Service_Amazon_S3 |

setHttpClient(\Zend_Http_Client $httpClient) : voidSets the HTTP client object to use for retrieving the feeds.
Inherited from: \Zend_Service_Abstract::setHttpClient()\Zend_Service_Amazon_Abstract::setHttpClient()If none is set, the default Zend_Http_Client will be used.
| Name | Type | Description |
|---|---|---|
| $httpClient | \Zend_Http_Client |

setKeys( $accessKey, $secretKey) : voidSet the keys to use when accessing SQS.
Inherited from: \Zend_Service_Amazon_Abstract::setKeys()| Name | Type | Description |
|---|---|---|
| $accessKey | ||
| $secretKey |

unregisterAsClient(string $name) : \Zend_Service_Amazon_S3Unregister this object as stream wrapper client
| Name | Type | Description |
|---|---|---|
| $name | string |
| Type | Description |
|---|---|
| \Zend_Service_Amazon_S3 |

unregisterStreamWrapper(string $name = 's3') : \Zend_Service_Amazon_S3Unregister this object as stream wrapper
| Name | Type | Description |
|---|---|---|
| $name | string |
| Type | Description |
|---|---|
| \Zend_Service_Amazon_S3 |