Service/Amazon/S3.php

Show: inherited
Table of Contents

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

Package: 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

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

Properties

Propertyprotectedstring $_accessKey =
inherited

<p>Amazon Access Key</p>Inherited from: \Zend_Service_Amazon_Abstract::$$_accessKey
Details
Type
string
Inherited_from
\Zend_Service_Amazon_Abstract::$$_accessKey  
Propertyprotectedstring $_defaultAccessKey = null
staticinherited

<p>Amazon Access Key</p>Inherited from: \Zend_Service_Amazon_Abstract::$$_defaultAccessKey
Default valuenullDetails
Type
string
Inherited_from
\Zend_Service_Amazon_Abstract::$$_defaultAccessKey  
Propertyprotectedstring $_defaultSecretKey = null
staticinherited

<p>Amazon Secret Key</p>Inherited from: \Zend_Service_Amazon_Abstract::$$_defaultSecretKey
Default valuenullDetails
Type
string
Inherited_from
\Zend_Service_Amazon_Abstract::$$_defaultSecretKey  
Propertyprotected\Zend_Uri_Http $_endpoint =

Endpoint for the service

Details
Type
\Zend_Uri_Http
Propertyprotected\Zend_Http_Client $_httpClient = null
staticinherited

HTTP Client used to query all web services

Inherited from: \Zend_Service_Abstract::$$_httpClient\Zend_Service_Amazon_Abstract::$$_httpClient
Default valuenullDetails
Type
\Zend_Http_Client
Inherited_from
\Zend_Service_Abstract::$$_httpClient  
Inherited_from
\Zend_Service_Amazon_Abstract::$$_httpClient  
Propertyprotectedstring $_secretKey =
inherited

<p>Amazon Secret Key</p>Inherited from: \Zend_Service_Amazon_Abstract::$$_secretKey
Details
Type
string
Inherited_from
\Zend_Service_Amazon_Abstract::$$_secretKey  
Propertyprotectedarray $_wrapperClients = array()
static

Store for stream wrapper clients

Default valuearray()Details
Type
array

Methods

methodpublic__construct(string $accessKey = null, string $secretKey = null, string $region = null) : void

Constructor

Parameters
Name Type Description
$accessKey string
$secretKey string
$region string
methodprotected_fixupObjectName(string $object) : string

Make sure the object name is valid

Parameters
Name Type Description
$object string
Returns
Type Description
string
methodprotected_getAccessKey() : string
inherited

Method to fetch the Access Key

Inherited from: \Zend_Service_Amazon_Abstract::_getAccessKey()
Returns
Type Description
string
methodprotected_getSecretKey() : string
inherited

Method to fetch the Secret AWS Key

Inherited from: \Zend_Service_Amazon_Abstract::_getSecretKey()
Returns
Type Description
string
methodpublic_makeRequest(string $method, string $path = '', array $params = null, array $headers = array(), string | resource $data = null) : \Zend_Http_Response

Make a request to Amazon S3

Parameters
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

Returns
Type Description
\Zend_Http_Response
methodpublic_validBucketName(string $bucket) : boolean

Verify if the bucket name is valid

Parameters
Name Type Description
$bucket string
Returns
Type Description
boolean
methodprotectedaddSignature(string $method, string $path, array $headers) : string

Add the S3 Authorization signature to the request headers

Parameters
Name Type Description
$method string
$path string
$headers array

&$headers

Returns
Type Description
string
methodpubliccleanBucket(string $bucket) : boolean

Remove all objects in the bucket.

Parameters
Name Type Description
$bucket string
Returns
Type Description
boolean
methodpubliccopyObject(string $sourceObject, string $destObject, array $meta = null) : boolean

Copy an object

Parameters
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.

Returns
Type Description
boolean
methodpubliccreateBucket(string $bucket,  $location = null) : boolean

Add a new bucket

Parameters
Name Type Description
$bucket string
$location
Returns
Type Description
boolean
methodpublicgetBuckets() : array | false

List the S3 buckets

Returns
Type Description
array | false
methodpublicgetEndpoint() : \Zend_Uri_Http

Get current S3 endpoint

Returns
Type Description
\Zend_Uri_Http
methodpublicgetHttpClient() : \Zend_Http_Client
staticfinalinherited

Gets the HTTP client object.

Inherited from: \Zend_Service_Abstract::getHttpClient()\Zend_Service_Amazon_Abstract::getHttpClient()
Returns
Type Description
\Zend_Http_Client
methodpublicgetInfo(string $object) : array | false

Get metadata information for a given object

Parameters
Name Type Description
$object string
Returns
Type Description
array | false
methodpublicgetMimeType(string $path) : string
static

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

Parameters
Name Type Description
$path string
Returns
Type Description
string
methodpublicgetObject(string $object, bool $paidobject = false) : string | false

Get an object

Parameters
Name Type Description
$object string
$paidobject bool

This is "requestor pays" object

Returns
Type Description
string | false
methodpublicgetObjectStream(string $object, string $streamfile = null, bool $paidobject = false) : \Zend_Http_Response_Stream | false

Get an object using streaming

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

Parameters
Name Type Description
$object string

Object path

$streamfile string

File to write the stream to

$paidobject bool

This is "requestor pays" object

Returns
Type Description
\Zend_Http_Response_Stream | false
methodpublicgetObjectsAndPrefixesByBucket(string $bucket, array $params = array()) : array | false

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.

Parameters
Name Type Description
$bucket string
$params array

S3 GET Bucket Paramater

Returns
Type Description
array | false
Details
See
\global\ZF-11401  
methodpublicgetObjectsByBucket(string $bucket, array $params = array()) : array | false

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
Name Type Description
$bucket string
$params array

S3 GET Bucket Paramater

Returns
Type Description
array | false
methodpublicgetWrapperClient(string $name) : \Zend_Service_Amazon_S3
static

Get wrapper client for stream type

Parameters
Name Type Description
$name string
Returns
Type Description
\Zend_Service_Amazon_S3
methodpublicisBucketAvailable(string $bucket) : boolean

Checks if a given bucket name is available

Parameters
Name Type Description
$bucket string
Returns
Type Description
boolean
methodpublicisObjectAvailable(string $object) : boolean

Checks if a given object exists

Parameters
Name Type Description
$object string
Returns
Type Description
boolean
methodpublicmoveObject(string $sourceObject, string $destObject, array $meta = null) : void

Move an object

Performs a copy to dest + verify + remove source

Parameters
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.

methodpublicputFile(string $path, string $object, array $meta = null) : boolean

Put file to S3 as object

Parameters
Name Type Description
$path string

File name

$object string

Object name

$meta array

Metadata

Returns
Type Description
boolean
methodpublicputFileStream(string $path, string $object, array $meta = null) : boolean

Put file to S3 as object, using streaming

Parameters
Name Type Description
$path string

File name

$object string

Object name

$meta array

Metadata

Returns
Type Description
boolean
methodpublicputObject(string $object, string | resource $data, array $meta = null) : boolean

Upload an object by a PHP string

Parameters
Name Type Description
$object string

Object name

$data string | resource

Object data (can be string or stream)

$meta array

Metadata

Returns
Type Description
boolean
methodpublicregisterAsClient(string $name) : \Zend_Service_Amazon_S3

Register this object as stream wrapper client

Parameters
Name Type Description
$name string
Returns
Type Description
\Zend_Service_Amazon_S3
methodpublicregisterStreamWrapper(string $name = 's3') : \Zend_Service_Amazon_S3

Register this object as stream wrapper

Parameters
Name Type Description
$name string
Returns
Type Description
\Zend_Service_Amazon_S3
methodpublicremoveBucket(string $bucket) : boolean

Remove a given bucket.

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

Parameters
Name Type Description
$bucket string
Returns
Type Description
boolean
methodpublicremoveObject(string $object) : boolean

Remove a given object

Parameters
Name Type Description
$object string
Returns
Type Description
boolean
methodpublicsetEndpoint(string | \Zend_Uri_Http $endpoint) : \Zend_Service_Amazon_S3

Set S3 endpoint to use

Parameters
Name Type Description
$endpoint string | \Zend_Uri_Http
Returns
Type Description
\Zend_Service_Amazon_S3
methodpublicsetHttpClient(\Zend_Http_Client $httpClient) : void
staticfinalinherited

Sets 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.

Parameters
Name Type Description
$httpClient \Zend_Http_Client
methodpublicsetKeys( $accessKey,  $secretKey) : void
staticinherited

Set the keys to use when accessing SQS.

Inherited from: \Zend_Service_Amazon_Abstract::setKeys()
Parameters
Name Type Description
$accessKey
$secretKey
methodpublicunregisterAsClient(string $name) : \Zend_Service_Amazon_S3

Unregister this object as stream wrapper client

Parameters
Name Type Description
$name string
Returns
Type Description
\Zend_Service_Amazon_S3
methodpublicunregisterStreamWrapper(string $name = 's3') : \Zend_Service_Amazon_S3

Unregister this object as stream wrapper

Parameters
Name Type Description
$name string
Returns
Type Description
\Zend_Service_Amazon_S3
Documentation was generated by phpDocumentor 2.0.0a8.