Differences Between: [Versions 310 and 400] [Versions 39 and 400] [Versions 400 and 402] [Versions 400 and 403]
Copyright (c) 2013, Donovan Schönknecht. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
File Size: | 2394 lines (74 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
S3:: (52 methods):
__construct()
setEndpoint()
setAuth()
hasAuth()
setSSL()
setSSLAuth()
setProxy()
setExceptions()
setTimeCorrectionOffset()
setSigningKey()
freeSigningKey()
__triggerError()
listBuckets()
getBucket()
putBucket()
deleteBucket()
inputFile()
inputResource()
putObject()
putObjectFile()
putObjectString()
getObject()
getObjectInfo()
copyObject()
setBucketRedirect()
setBucketLogging()
getBucketLogging()
disableBucketLogging()
getBucketLocation()
setAccessControlPolicy()
getAccessControlPolicy()
deleteObject()
getAuthenticatedURL()
getSignedPolicyURL()
getSignedCannedURL()
getHttpUploadPostParams()
createDistribution()
getDistribution()
updateDistribution()
deleteDistribution()
listDistributions()
listOriginAccessIdentities()
invalidateDistribution()
__getCloudFrontInvalidationBatchXML()
getDistributionInvalidationList()
__getCloudFrontDistributionConfigXML()
__parseCloudFrontDistributionConfig()
__getCloudFrontResponse()
__getMIMEType()
__getTime()
__getSignature()
__getHash()
S3Request:: (9 methods):
__construct()
setParameter()
setHeader()
setAmzHeader()
getResponse()
__sortMetaHeadersCmp()
__responseWriteCallback()
__dnsBucketName()
__responseHeaderCallback()
S3Exception:: (1 method):
__construct()
__construct($accessKey = null, $secretKey = null, $useSSL = false, $endpoint = 's3.amazonaws.com') X-Ref |
Constructor - if you're not using the class statically return: void param: string $accessKey Access key param: string $secretKey Secret key param: boolean $useSSL Enable SSL param: string $endpoint Amazon URI |
setEndpoint($host) X-Ref |
Set the service endpoint return: void param: string $host Hostname |
setAuth($accessKey, $secretKey) X-Ref |
Set AWS access key and secret key return: void param: string $accessKey Access key param: string $secretKey Secret key |
hasAuth() X-Ref |
Check if AWS keys have been set return: boolean |
setSSL($enabled, $validate = true) X-Ref |
Set SSL on or off return: void param: boolean $enabled SSL enabled param: boolean $validate SSL certificate validation |
setSSLAuth($sslCert = null, $sslKey = null, $sslCACert = null) X-Ref |
Set SSL client certificates (experimental) return: void param: string $sslCert SSL client certificate param: string $sslKey SSL client key param: string $sslCACert SSL CA cert (only required if you are having problems with your system CA cert) |
setProxy($host, $user = null, $pass = null, $type = CURLPROXY_SOCKS5) X-Ref |
Set proxy information return: void param: string $host Proxy hostname and port (localhost:1234) param: string $user Proxy username param: string $pass Proxy password param: constant $type CURL proxy type |
setExceptions($enabled = true) X-Ref |
Set the error mode to exceptions return: void param: boolean $enabled Enable exceptions |
setTimeCorrectionOffset($offset = 0) X-Ref |
Set AWS time correction offset (use carefully) This can be used when an inaccurate system time is generating invalid request signatures. It should only be used as a last resort when the system time cannot be changed. return: void param: string $offset Time offset (set to zero to use AWS server time) |
setSigningKey($keyPairId, $signingKey, $isFile = true) X-Ref |
Set signing key return: boolean param: string $keyPairId AWS Key Pair ID param: string $signingKey Private Key param: boolean $isFile Load private key from file, set to false to load string |
freeSigningKey() X-Ref |
Free signing key from memory, MUST be called if you are using setSigningKey() return: void |
__triggerError($message, $file, $line, $code = 0) X-Ref |
Internal error handler return: void param: string $message Error message param: string $file Filename param: integer $line Line number param: integer $code Error code |
listBuckets($detailed = false) X-Ref |
Get a list of buckets return: array | false param: boolean $detailed Returns detailed bucket list when true |
getBucket($bucket, $prefix = null, $marker = null, $maxKeys = null, $delimiter = null, $returnCommonPrefixes = false) X-Ref |
Get contents for a bucket If maxKeys is null this method will loop through truncated result sets return: array | false param: string $bucket Bucket name param: string $prefix Prefix param: string $marker Marker (last file listed) param: string $maxKeys Max keys (maximum number of keys to return) param: string $delimiter Delimiter param: boolean $returnCommonPrefixes Set to true to return CommonPrefixes |
putBucket($bucket, $acl = self::ACL_PRIVATE, $location = false) X-Ref |
Put a bucket return: boolean param: string $bucket Bucket name param: constant $acl ACL flag param: string $location Set as "EU" to create buckets hosted in Europe |
deleteBucket($bucket) X-Ref |
Delete an empty bucket return: boolean param: string $bucket Bucket name |
inputFile($file, $md5sum = true) X-Ref |
Create input info array for putObject() return: array | false param: string $file Input file param: mixed $md5sum Use MD5 hash (supply a string if you want to use your own) |
inputResource(&$resource, $bufferSize = false, $md5sum = '') X-Ref |
Create input array info for putObject() with a resource return: array | false param: string $resource Input resource to read from param: integer $bufferSize Input byte size param: string $md5sum MD5 hash to send (optional) |
putObject($input, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array() X-Ref |
Put an object return: boolean param: mixed $input Input data param: string $bucket Bucket name param: string $uri Object URI param: constant $acl ACL constant param: array $metaHeaders Array of x-amz-meta-* headers param: array $requestHeaders Array of request headers or content type as a string param: constant $storageClass Storage class constant param: constant $serverSideEncryption Server-side encryption |
putObjectFile($file, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array() X-Ref |
Put an object from a file (legacy function) return: boolean param: string $file Input file path param: string $bucket Bucket name param: string $uri Object URI param: constant $acl ACL constant param: array $metaHeaders Array of x-amz-meta-* headers param: string $contentType Content type |
putObjectString($string, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array() X-Ref |
Put an object from a string (legacy function) return: boolean param: string $string Input data param: string $bucket Bucket name param: string $uri Object URI param: constant $acl ACL constant param: array $metaHeaders Array of x-amz-meta-* headers param: string $contentType Content type |
getObject($bucket, $uri, $saveTo = false) X-Ref |
Get an object return: mixed param: string $bucket Bucket name param: string $uri Object URI param: mixed $saveTo Filename or resource to write to |
getObjectInfo($bucket, $uri, $returnInfo = true) X-Ref |
Get object information return: mixed | false param: string $bucket Bucket name param: string $uri Object URI param: boolean $returnInfo Return response information |
copyObject($srcBucket, $srcUri, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array() X-Ref |
Copy an object return: mixed | false param: string $srcBucket Source bucket name param: string $srcUri Source object URI param: string $bucket Destination bucket name param: string $uri Destination object URI param: constant $acl ACL constant param: array $metaHeaders Optional array of x-amz-meta-* headers param: array $requestHeaders Optional array of request headers (content type, disposition, etc.) param: constant $storageClass Storage class constant |
setBucketRedirect($bucket = NULL, $location = NULL) X-Ref |
Set up a bucket redirection return: boolean param: string $bucket Bucket name param: string $location Target host name |
setBucketLogging($bucket, $targetBucket, $targetPrefix = null) X-Ref |
Set logging for a bucket return: boolean param: string $bucket Bucket name param: string $targetBucket Target bucket (where logs are stored) param: string $targetPrefix Log prefix (e,g; domain.com-) |
getBucketLogging($bucket) X-Ref |
Get logging status for a bucket This will return false if logging is not enabled. Note: To enable logging, you also need to grant write access to the log group return: array | false param: string $bucket Bucket name |
disableBucketLogging($bucket) X-Ref |
Disable bucket logging return: boolean param: string $bucket Bucket name |
getBucketLocation($bucket) X-Ref |
Get a bucket's location return: string | false param: string $bucket Bucket name |
setAccessControlPolicy($bucket, $uri = '', $acp = array() X-Ref |
Set object or bucket Access Control Policy return: boolean param: string $bucket Bucket name param: string $uri Object URI param: array $acp Access Control Policy Data (same as the data returned from getAccessControlPolicy) |
getAccessControlPolicy($bucket, $uri = '') X-Ref |
Get object or bucket Access Control Policy return: mixed | false param: string $bucket Bucket name param: string $uri Object URI |
deleteObject($bucket, $uri) X-Ref |
Delete an object return: boolean param: string $bucket Bucket name param: string $uri Object URI |
getAuthenticatedURL($bucket, $uri, $lifetime, $hostBucket = false, $https = false) X-Ref |
Get a query string authenticated URL return: string param: string $bucket Bucket name param: string $uri Object URI param: integer $lifetime Lifetime in seconds param: boolean $hostBucket Use the bucket name as the hostname param: boolean $https Use HTTPS ($hostBucket should be false for SSL verification) |
getSignedPolicyURL($policy) X-Ref |
Get a CloudFront signed policy URL return: string param: array $policy Policy |
getSignedCannedURL($url, $lifetime) X-Ref |
Get a CloudFront canned policy URL return: string param: string $url URL to sign param: integer $lifetime URL lifetime |
getHttpUploadPostParams($bucket, $uriPrefix = '', $acl = self::ACL_PRIVATE, $lifetime = 3600,$maxFileSize = 5242880, $successRedirect = "201", $amzHeaders = array() X-Ref |
Get upload POST parameters for form uploads return: object param: string $bucket Bucket name param: string $uriPrefix Object URI prefix param: constant $acl ACL constant param: integer $lifetime Lifetime in seconds param: integer $maxFileSize Maximum filesize in bytes (default 5MB) param: string $successRedirect Redirect URL or 200 / 201 status code param: array $amzHeaders Array of x-amz-meta-* headers param: array $headers Array of request headers or content type as a string param: boolean $flashVars Includes additional "Filename" variable posted by Flash |
createDistribution($bucket, $enabled = true, $cnames = array() X-Ref |
Create a CloudFront distribution return: array | false param: string $bucket Bucket name param: boolean $enabled Enabled (true/false) param: array $cnames Array containing CNAME aliases param: string $comment Use the bucket name as the hostname param: string $defaultRootObject Default root object param: string $originAccessIdentity Origin access identity param: array $trustedSigners Array of trusted signers |
getDistribution($distributionId) X-Ref |
Get CloudFront distribution info return: array | false param: string $distributionId Distribution ID from listDistributions() |
updateDistribution($dist) X-Ref |
Update a CloudFront distribution return: array | false param: array $dist Distribution array info identical to output of getDistribution() |
deleteDistribution($dist) X-Ref |
Delete a CloudFront distribution return: boolean param: array $dist Distribution array info identical to output of getDistribution() |
listDistributions() X-Ref |
Get a list of CloudFront distributions return: array |
listOriginAccessIdentities() X-Ref |
List CloudFront Origin Access Identities return: array |
invalidateDistribution($distributionId, $paths) X-Ref |
Invalidate objects in a CloudFront distribution Thanks to Martin Lindkvist for S3::invalidateDistribution() return: boolean param: string $distributionId Distribution ID from listDistributions() param: array $paths Array of object paths to invalidate |
__getCloudFrontInvalidationBatchXML($paths, $callerReference = '0') X-Ref |
Get a InvalidationBatch DOMDocument return: string param: array $paths Paths to objects to invalidateDistribution param: int $callerReference |
getDistributionInvalidationList($distributionId) X-Ref |
List your invalidation batches for invalidateDistribution() in a CloudFront distribution http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/ListInvalidation.html returned array looks like this: Array ( [I31TWB0CN9V6XD] => InProgress [IT3TFE31M0IHZ] => Completed [I12HK7MPO1UQDA] => Completed [I1IA7R6JKTC3L2] => Completed ) return: array param: string $distributionId Distribution ID from listDistributions() |
__getCloudFrontDistributionConfigXML($bucket, $enabled, $comment, $callerReference = '0', $cnames = array() X-Ref |
Get a DistributionConfig DOMDocument http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/index.html?PutConfig.html return: string param: string $bucket S3 Origin bucket param: boolean $enabled Enabled (true/false) param: string $comment Comment to append param: string $callerReference Caller reference param: array $cnames Array of CNAME aliases param: string $defaultRootObject Default root object param: string $originAccessIdentity Origin access identity param: array $trustedSigners Array of trusted signers |
__parseCloudFrontDistributionConfig(&$node) X-Ref |
Parse a CloudFront distribution config See http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/index.html?GetDistribution.html return: array param: object &$node DOMNode |
__getCloudFrontResponse(&$rest) X-Ref |
Grab CloudFront response return: object param: object &$rest S3Request instance |
__getMIMEType(&$file) X-Ref |
Get MIME type for file To override the putObject() Content-Type, add it to $requestHeaders To use fileinfo, ensure the MAGIC environment variable is set return: string param: string &$file File path |
__getTime() X-Ref |
Get the current time return: integer |
__getSignature($string) X-Ref |
Generate the auth string: "AWS AccessKey:Signature" return: string param: string $string String to sign |
__getHash($string) X-Ref |
Creates a HMAC-SHA1 hash This uses the hash extension if loaded return: string param: string $string String to sign |
__construct($verb, $bucket = '', $uri = '', $endpoint = 's3.amazonaws.com') X-Ref |
Constructor return: mixed param: string $verb Verb param: string $bucket Bucket name param: string $uri Object URI param: string $endpoint AWS endpoint URI |
setParameter($key, $value) X-Ref |
Set request parameter return: void param: string $key Key param: string $value Value |
setHeader($key, $value) X-Ref |
Set request header return: void param: string $key Key param: string $value Value |
setAmzHeader($key, $value) X-Ref |
Set x-amz-meta-* header return: void param: string $key Key param: string $value Value |
getResponse() X-Ref |
Get the S3 response return: object | false |
__sortMetaHeadersCmp($a, $b) X-Ref |
Sort compare for meta headers return: integer param: string $a String A param: string $b String B |
__responseWriteCallback(&$curl, &$data) X-Ref |
CURL write callback return: integer param: resource &$curl CURL resource param: string &$data Data |
__dnsBucketName($bucket) X-Ref |
Check DNS conformity return: boolean param: string $bucket Bucket name |
__responseHeaderCallback($curl, $data) X-Ref |
CURL header callback return: integer param: resource $curl CURL resource param: string $data Data |