PHP 클래스 S3

파일 보기 프로젝트 열기: tpyo/amazon-s3-php-class 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$defDelimiter string Default delimiter to be used, for example while getBucket().
$endpoint string AWS URI
$proxy null | array Proxy information
$sslCACert string SSL CA cert (only required if you are having problems with your system CA cert)
$sslCert string SSL client certfificate
$sslKey boolean SSL client key
$useExceptions boolean Use PHP exceptions?
$useSSL boolean Connect using SSL?
$useSSLValidation boolean Use SSL validation?
$useSSLVersion const Use SSL version

공개 메소드들

메소드 설명
__construct ( string $accessKey = null, string $secretKey = null, boolean $useSSL = false, string $endpoint = 's3.amazonaws.com' ) : void Constructor - if you're not using the class statically
__getSignature ( string $string ) : string Generate the auth string: "AWS AccessKey:Signature"
__getTime ( ) : integer Get the current time
copyObject ( string $srcBucket, string $srcUri, string $bucket, string $uri, constant $acl = self::ACL_PRIVATE, array $metaHeaders = [], array $requestHeaders = [], constant $storageClass = self::STORAGE_CLASS_STANDARD ) : mixed | false Copy an object
createDistribution ( string $bucket, boolean $enabled = true, array $cnames = [], string $comment = null, string $defaultRootObject = null, string $originAccessIdentity = null, array $trustedSigners = [] ) : array | false Create a CloudFront distribution
deleteBucket ( string $bucket ) : boolean Delete an empty bucket
deleteDistribution ( array $dist ) : boolean Delete a CloudFront distribution
deleteObject ( string $bucket, string $uri ) : boolean Delete an object
disableBucketLogging ( string $bucket ) : boolean Disable bucket logging
freeSigningKey ( ) : void Free signing key from memory, MUST be called if you are using setSigningKey()
getAccessControlPolicy ( string $bucket, string $uri = '' ) : mixed | false Get object or bucket Access Control Policy
getAuthenticatedURL ( string $bucket, string $uri, integer $lifetime, boolean $hostBucket = false, boolean $https = false ) : string Get a query string authenticated URL
getBucket ( string $bucket, string $prefix = null, string $marker = null, string $maxKeys = null, string $delimiter = null, boolean $returnCommonPrefixes = false ) : array | false Get contents for a bucket
getBucketLocation ( string $bucket ) : string | false Get a bucket's location
getBucketLogging ( string $bucket ) : array | false Get logging status for a bucket
getDistribution ( string $distributionId ) : array | false Get CloudFront distribution info
getDistributionInvalidationList ( string $distributionId ) : array List your invalidation batches for invalidateDistribution() in a CloudFront distribution
getHttpUploadPostParams ( string $bucket, string $uriPrefix = '', constant $acl = self::ACL_PRIVATE, integer $lifetime = 3600, integer $maxFileSize = 5242880, string $successRedirect = "201", array $amzHeaders = [], array $headers = [], boolean $flashVars = false ) : object Get upload POST parameters for form uploads
getObject ( string $bucket, string $uri, mixed $saveTo = false ) : mixed Get an object
getObjectInfo ( string $bucket, string $uri, boolean $returnInfo = true ) : mixed | false Get object information
getSignedCannedURL ( string $url, integer $lifetime ) : string Get a CloudFront canned policy URL
getSignedPolicyURL ( array $policy ) : string Get a CloudFront signed policy URL
hasAuth ( ) : boolean Check if AWS keys have been set
inputFile ( string $file, mixed $md5sum = true ) : array | false Create input info array for putObject()
inputResource ( string &$resource, integer $bufferSize = false, string $md5sum = '' ) : array | false Create input array info for putObject() with a resource
invalidateDistribution ( string $distributionId, array $paths ) : boolean Invalidate objects in a CloudFront distribution
listBuckets ( boolean $detailed = false ) : array | false Get a list of buckets
listDistributions ( ) : array Get a list of CloudFront distributions
listOriginAccessIdentities ( ) : array List CloudFront Origin Access Identities
putBucket ( string $bucket, constant $acl = self::ACL_PRIVATE, string $location = false ) : boolean Put a bucket
putObject ( mixed $input, string $bucket, string $uri, constant $acl = self::ACL_PRIVATE, array $metaHeaders = [], array $requestHeaders = [], constant $storageClass = self::STORAGE_CLASS_STANDARD, constant $serverSideEncryption = self::SSE_NONE ) : boolean Put an object
putObjectFile ( string $file, string $bucket, string $uri, constant $acl = self::ACL_PRIVATE, array $metaHeaders = [], string $contentType = null ) : boolean Put an object from a file (legacy function)
putObjectString ( string $string, string $bucket, string $uri, constant $acl = self::ACL_PRIVATE, array $metaHeaders = [], string $contentType = 'text/plain' ) : boolean Put an object from a string (legacy function)
setAccessControlPolicy ( string $bucket, string $uri = '', array $acp = [] ) : boolean Set object or bucket Access Control Policy
setAuth ( string $accessKey, string $secretKey ) : void Set AWS access key and secret key
setBucketLogging ( string $bucket, string $targetBucket, string $targetPrefix = null ) : boolean Set logging for a bucket
setBucketRedirect ( string $bucket = NULL, string $location = NULL ) : boolean Set up a bucket redirection
setEndpoint ( string $host ) : void Set the service endpoint
setExceptions ( boolean $enabled = true ) : void Set the error mode to exceptions
setProxy ( string $host, string $user = null, string $pass = null, constant $type = CURLPROXY_SOCKS5 ) : void Set proxy information
setSSL ( boolean $enabled, boolean $validate = true ) : void Set SSL on or off
setSSLAuth ( string $sslCert = null, string $sslKey = null, string $sslCACert = null ) : void Set SSL client certificates (experimental)
setSigningKey ( string $keyPairId, string $signingKey, boolean $isFile = true ) : boolean Set signing key
setTimeCorrectionOffset ( string $offset ) : void Set AWS time correction offset (use carefully)
updateDistribution ( array $dist ) : array | false Update a CloudFront distribution

비공개 메소드들

메소드 설명
__getCloudFrontDistributionConfigXML ( string $bucket, boolean $enabled, string $comment, string $callerReference = '0', array $cnames = [], string $defaultRootObject = null, string $originAccessIdentity = null, array $trustedSigners = [] ) : string Get a DistributionConfig DOMDocument
__getCloudFrontInvalidationBatchXML ( array $paths, integer $callerReference = '0' ) : string Get a InvalidationBatch DOMDocument
__getCloudFrontResponse ( &$rest ) : object Grab CloudFront response
__getHash ( string $string ) : string Creates a HMAC-SHA1 hash
__getMIMEType ( &$file ) : string Get MIME type for file
__parseCloudFrontDistributionConfig ( &$node ) : array Parse a CloudFront distribution config
__triggerError ( string $message, string $file, integer $line, integer $code ) : void Internal error handler

메소드 상세

__construct() 공개 메소드

Constructor - if you're not using the class statically
public __construct ( string $accessKey = null, string $secretKey = null, boolean $useSSL = false, string $endpoint = 's3.amazonaws.com' ) : void
$accessKey string Access key
$secretKey string Secret key
$useSSL boolean Enable SSL
$endpoint string Amazon URI
리턴 void

__getSignature() 공개 정적인 메소드

Generate the auth string: "AWS AccessKey:Signature"
public static __getSignature ( string $string ) : string
$string string String to sign
리턴 string

__getTime() 공개 정적인 메소드

Get the current time
public static __getTime ( ) : integer
리턴 integer

copyObject() 공개 정적인 메소드

Copy an object
public static copyObject ( string $srcBucket, string $srcUri, string $bucket, string $uri, constant $acl = self::ACL_PRIVATE, array $metaHeaders = [], array $requestHeaders = [], constant $storageClass = self::STORAGE_CLASS_STANDARD ) : mixed | false
$srcBucket string Source bucket name
$srcUri string Source object URI
$bucket string Destination bucket name
$uri string Destination object URI
$acl constant ACL constant
$metaHeaders array Optional array of x-amz-meta-* headers
$requestHeaders array Optional array of request headers (content type, disposition, etc.)
$storageClass constant Storage class constant
리턴 mixed | false | false

createDistribution() 공개 정적인 메소드

Create a CloudFront distribution
public static createDistribution ( string $bucket, boolean $enabled = true, array $cnames = [], string $comment = null, string $defaultRootObject = null, string $originAccessIdentity = null, array $trustedSigners = [] ) : array | false
$bucket string Bucket name
$enabled boolean Enabled (true/false)
$cnames array Array containing CNAME aliases
$comment string Use the bucket name as the hostname
$defaultRootObject string Default root object
$originAccessIdentity string Origin access identity
$trustedSigners array Array of trusted signers
리턴 array | false | false

deleteBucket() 공개 정적인 메소드

Delete an empty bucket
public static deleteBucket ( string $bucket ) : boolean
$bucket string Bucket name
리턴 boolean

deleteDistribution() 공개 정적인 메소드

Delete a CloudFront distribution
public static deleteDistribution ( array $dist ) : boolean
$dist array Distribution array info identical to output of getDistribution()
리턴 boolean

deleteObject() 공개 정적인 메소드

Delete an object
public static deleteObject ( string $bucket, string $uri ) : boolean
$bucket string Bucket name
$uri string Object URI
리턴 boolean

disableBucketLogging() 공개 정적인 메소드

Disable bucket logging
public static disableBucketLogging ( string $bucket ) : boolean
$bucket string Bucket name
리턴 boolean

freeSigningKey() 공개 정적인 메소드

Free signing key from memory, MUST be called if you are using setSigningKey()
public static freeSigningKey ( ) : void
리턴 void

getAccessControlPolicy() 공개 정적인 메소드

Get object or bucket Access Control Policy
public static getAccessControlPolicy ( string $bucket, string $uri = '' ) : mixed | false
$bucket string Bucket name
$uri string Object URI
리턴 mixed | false | false

getAuthenticatedURL() 공개 정적인 메소드

Get a query string authenticated URL
public static getAuthenticatedURL ( string $bucket, string $uri, integer $lifetime, boolean $hostBucket = false, boolean $https = false ) : string
$bucket string Bucket name
$uri string Object URI
$lifetime integer Lifetime in seconds
$hostBucket boolean Use the bucket name as the hostname
$https boolean Use HTTPS ($hostBucket should be false for SSL verification)
리턴 string

getBucket() 공개 정적인 메소드

If maxKeys is null this method will loop through truncated result sets
public static getBucket ( string $bucket, string $prefix = null, string $marker = null, string $maxKeys = null, string $delimiter = null, boolean $returnCommonPrefixes = false ) : array | false
$bucket string Bucket name
$prefix string Prefix
$marker string Marker (last file listed)
$maxKeys string Max keys (maximum number of keys to return)
$delimiter string Delimiter
$returnCommonPrefixes boolean Set to true to return CommonPrefixes
리턴 array | false | false

getBucketLocation() 공개 정적인 메소드

Get a bucket's location
public static getBucketLocation ( string $bucket ) : string | false
$bucket string Bucket name
리턴 string | false | false

getBucketLogging() 공개 정적인 메소드

This will return false if logging is not enabled. Note: To enable logging, you also need to grant write access to the log group
public static getBucketLogging ( string $bucket ) : array | false
$bucket string Bucket name
리턴 array | false | false

getDistribution() 공개 정적인 메소드

Get CloudFront distribution info
public static getDistribution ( string $distributionId ) : array | false
$distributionId string Distribution ID from listDistributions()
리턴 array | false | false

getDistributionInvalidationList() 공개 정적인 메소드

http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/ListInvalidation.html returned array looks like this: Array ( [I31TWB0CN9V6XD] => InProgress [IT3TFE31M0IHZ] => Completed [I12HK7MPO1UQDA] => Completed [I1IA7R6JKTC3L2] => Completed )
public static getDistributionInvalidationList ( string $distributionId ) : array
$distributionId string Distribution ID from listDistributions()
리턴 array

getHttpUploadPostParams() 공개 정적인 메소드

Get upload POST parameters for form uploads
public static getHttpUploadPostParams ( string $bucket, string $uriPrefix = '', constant $acl = self::ACL_PRIVATE, integer $lifetime = 3600, integer $maxFileSize = 5242880, string $successRedirect = "201", array $amzHeaders = [], array $headers = [], boolean $flashVars = false ) : object
$bucket string Bucket name
$uriPrefix string Object URI prefix
$acl constant ACL constant
$lifetime integer Lifetime in seconds
$maxFileSize integer Maximum filesize in bytes (default 5MB)
$successRedirect string Redirect URL or 200 / 201 status code
$amzHeaders array Array of x-amz-meta-* headers
$headers array Array of request headers or content type as a string
$flashVars boolean Includes additional "Filename" variable posted by Flash
리턴 object

getObject() 공개 정적인 메소드

Get an object
public static getObject ( string $bucket, string $uri, mixed $saveTo = false ) : mixed
$bucket string Bucket name
$uri string Object URI
$saveTo mixed Filename or resource to write to
리턴 mixed

getObjectInfo() 공개 정적인 메소드

Get object information
public static getObjectInfo ( string $bucket, string $uri, boolean $returnInfo = true ) : mixed | false
$bucket string Bucket name
$uri string Object URI
$returnInfo boolean Return response information
리턴 mixed | false | false

getSignedCannedURL() 공개 정적인 메소드

Get a CloudFront canned policy URL
public static getSignedCannedURL ( string $url, integer $lifetime ) : string
$url string URL to sign
$lifetime integer URL lifetime
리턴 string

getSignedPolicyURL() 공개 정적인 메소드

Get a CloudFront signed policy URL
public static getSignedPolicyURL ( array $policy ) : string
$policy array Policy
리턴 string

hasAuth() 공개 정적인 메소드

Check if AWS keys have been set
public static hasAuth ( ) : boolean
리턴 boolean

inputFile() 공개 정적인 메소드

Create input info array for putObject()
public static inputFile ( string $file, mixed $md5sum = true ) : array | false
$file string Input file
$md5sum mixed Use MD5 hash (supply a string if you want to use your own)
리턴 array | false | false

inputResource() 공개 정적인 메소드

Create input array info for putObject() with a resource
public static inputResource ( string &$resource, integer $bufferSize = false, string $md5sum = '' ) : array | false
$resource string Input resource to read from
$bufferSize integer Input byte size
$md5sum string MD5 hash to send (optional)
리턴 array | false | false

invalidateDistribution() 공개 정적인 메소드

Thanks to Martin Lindkvist for S3::invalidateDistribution()
public static invalidateDistribution ( string $distributionId, array $paths ) : boolean
$distributionId string Distribution ID from listDistributions()
$paths array Array of object paths to invalidate
리턴 boolean

listBuckets() 공개 정적인 메소드

Get a list of buckets
public static listBuckets ( boolean $detailed = false ) : array | false
$detailed boolean Returns detailed bucket list when true
리턴 array | false | false

listDistributions() 공개 정적인 메소드

Get a list of CloudFront distributions
public static listDistributions ( ) : array
리턴 array

listOriginAccessIdentities() 공개 정적인 메소드

List CloudFront Origin Access Identities
public static listOriginAccessIdentities ( ) : array
리턴 array

putBucket() 공개 정적인 메소드

Put a bucket
public static putBucket ( string $bucket, constant $acl = self::ACL_PRIVATE, string $location = false ) : boolean
$bucket string Bucket name
$acl constant ACL flag
$location string Set as "EU" to create buckets hosted in Europe
리턴 boolean

putObject() 공개 정적인 메소드

Put an object
public static putObject ( mixed $input, string $bucket, string $uri, constant $acl = self::ACL_PRIVATE, array $metaHeaders = [], array $requestHeaders = [], constant $storageClass = self::STORAGE_CLASS_STANDARD, constant $serverSideEncryption = self::SSE_NONE ) : boolean
$input mixed Input data
$bucket string Bucket name
$uri string Object URI
$acl constant ACL constant
$metaHeaders array Array of x-amz-meta-* headers
$requestHeaders array Array of request headers or content type as a string
$storageClass constant Storage class constant
$serverSideEncryption constant Server-side encryption
리턴 boolean

putObjectFile() 공개 정적인 메소드

Put an object from a file (legacy function)
public static putObjectFile ( string $file, string $bucket, string $uri, constant $acl = self::ACL_PRIVATE, array $metaHeaders = [], string $contentType = null ) : boolean
$file string Input file path
$bucket string Bucket name
$uri string Object URI
$acl constant ACL constant
$metaHeaders array Array of x-amz-meta-* headers
$contentType string Content type
리턴 boolean

putObjectString() 공개 정적인 메소드

Put an object from a string (legacy function)
public static putObjectString ( string $string, string $bucket, string $uri, constant $acl = self::ACL_PRIVATE, array $metaHeaders = [], string $contentType = 'text/plain' ) : boolean
$string string Input data
$bucket string Bucket name
$uri string Object URI
$acl constant ACL constant
$metaHeaders array Array of x-amz-meta-* headers
$contentType string Content type
리턴 boolean

setAccessControlPolicy() 공개 정적인 메소드

Set object or bucket Access Control Policy
public static setAccessControlPolicy ( string $bucket, string $uri = '', array $acp = [] ) : boolean
$bucket string Bucket name
$uri string Object URI
$acp array Access Control Policy Data (same as the data returned from getAccessControlPolicy)
리턴 boolean

setAuth() 공개 정적인 메소드

Set AWS access key and secret key
public static setAuth ( string $accessKey, string $secretKey ) : void
$accessKey string Access key
$secretKey string Secret key
리턴 void

setBucketLogging() 공개 정적인 메소드

Set logging for a bucket
public static setBucketLogging ( string $bucket, string $targetBucket, string $targetPrefix = null ) : boolean
$bucket string Bucket name
$targetBucket string Target bucket (where logs are stored)
$targetPrefix string Log prefix (e,g; domain.com-)
리턴 boolean

setBucketRedirect() 공개 정적인 메소드

Set up a bucket redirection
public static setBucketRedirect ( string $bucket = NULL, string $location = NULL ) : boolean
$bucket string Bucket name
$location string Target host name
리턴 boolean

setEndpoint() 공개 메소드

Set the service endpoint
public setEndpoint ( string $host ) : void
$host string Hostname
리턴 void

setExceptions() 공개 정적인 메소드

Set the error mode to exceptions
public static setExceptions ( boolean $enabled = true ) : void
$enabled boolean Enable exceptions
리턴 void

setProxy() 공개 정적인 메소드

Set proxy information
public static setProxy ( string $host, string $user = null, string $pass = null, constant $type = CURLPROXY_SOCKS5 ) : void
$host string Proxy hostname and port (localhost:1234)
$user string Proxy username
$pass string Proxy password
$type constant CURL proxy type
리턴 void

setSSL() 공개 정적인 메소드

Set SSL on or off
public static setSSL ( boolean $enabled, boolean $validate = true ) : void
$enabled boolean SSL enabled
$validate boolean SSL certificate validation
리턴 void

setSSLAuth() 공개 정적인 메소드

Set SSL client certificates (experimental)
public static setSSLAuth ( string $sslCert = null, string $sslKey = null, string $sslCACert = null ) : void
$sslCert string SSL client certificate
$sslKey string SSL client key
$sslCACert string SSL CA cert (only required if you are having problems with your system CA cert)
리턴 void

setSigningKey() 공개 정적인 메소드

Set signing key
public static setSigningKey ( string $keyPairId, string $signingKey, boolean $isFile = true ) : boolean
$keyPairId string AWS Key Pair ID
$signingKey string Private Key
$isFile boolean Load private key from file, set to false to load string
리턴 boolean

setTimeCorrectionOffset() 공개 정적인 메소드

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.
public static setTimeCorrectionOffset ( string $offset ) : void
$offset string Time offset (set to zero to use AWS server time)
리턴 void

updateDistribution() 공개 정적인 메소드

Update a CloudFront distribution
public static updateDistribution ( array $dist ) : array | false
$dist array Distribution array info identical to output of getDistribution()
리턴 array | false | false

프로퍼티 상세

$defDelimiter 공개적으로 정적으로 프로퍼티

Default delimiter to be used, for example while getBucket().
public static string $defDelimiter
리턴 string

$endpoint 공개적으로 정적으로 프로퍼티

AWS URI
public static string $endpoint
리턴 string

$proxy 공개적으로 정적으로 프로퍼티

Proxy information
public static null|array $proxy
리턴 null | array

$sslCACert 공개적으로 정적으로 프로퍼티

SSL CA cert (only required if you are having problems with your system CA cert)
public static string $sslCACert
리턴 string

$sslCert 공개적으로 정적으로 프로퍼티

SSL client certfificate
public static string $sslCert
리턴 string

$sslKey 공개적으로 정적으로 프로퍼티

SSL client key
public static bool $sslKey
리턴 boolean

$useExceptions 공개적으로 정적으로 프로퍼티

Use PHP exceptions?
public static bool $useExceptions
리턴 boolean

$useSSL 공개적으로 정적으로 프로퍼티

Connect using SSL?
public static bool $useSSL
리턴 boolean

$useSSLValidation 공개적으로 정적으로 프로퍼티

Use SSL validation?
public static bool $useSSLValidation
리턴 boolean

$useSSLVersion 공개적으로 정적으로 프로퍼티

Use SSL version
public static const $useSSLVersion
리턴 const