Skip to content

Latest commit

 

History

History
135 lines (106 loc) · 8.11 KB

API.md

File metadata and controls

135 lines (106 loc) · 8.11 KB

API

Class frostealth\yii2\aws\s3\Storage

Implements: frostealth\yii2\aws\s3\StorageInterface

Inheritance: yii\base\Component

Public properties

Property Type Required Description
$credentials Aws\Credentials\CredentialsInterface|array|callable yes Specifies the credentials used to sign requests.
$region string yes Region to connect to. Available regions.
$bucket string yes The bucket name.
$debug boolean|array no Set to true to display debug information when sending requests.
$options array no Other S3Client options.
$defaultAcl string no Default ACL.
$cdnHostname string no The full URL of the CloudFront.

Constants

Constant Value
ACL_PRIVATE 'private'
ACL_PUBLIC_READ 'public-read'
ACL_PUBLIC_READ_WRITE 'public-read-write'
ACL_AUTHENTICATED_READ 'authenticated-read'
ACL_BUCKET_OWNER_READ 'bucket-owner-read'
ALC_BUCKET_OWNER_FULL_CONTROL 'bucket-owner-full-control'

Public methods

put($filename, $data, $acl = null, array $options = [])

Adds an object to a bucket.

Argument Type Description
$filename string
$data mixed Object data to upload. Can be a Psr\Http\Message\StreamInterface, php stream resource, or a string of data to upload.
$acl string ACL to apply to the object.
$options array Other parameters.
return Aws\ResultInterface See result syntax.

get($filename, $saveAs = null)

Retrieves an object from Amazon S3.

Argument Type Description
$filename string
$saveAs string The path to a file on disk to save the object data.
return Aws\ResultInterface See result syntax.

exist($filename, array $options = [])

Determines whether or not an object exists by name.

Argument Type Description
$filename string
$options array Additional options available in the HeadObject operation (e.g., VersionId).
return boolean

delete($filename)

Removes an object from Amazon S3.

Argument Type Description
$filename string
return Aws\ResultInterface See result syntax.

getUrl($filename)

Returns the URL to an object identified by its bucket and key.

Argument Type Description
$filename string
return string

getPresignedUrl($filename, $expires)

Create a pre-signed URL.

Argument Type Description
$filename string
$expires string|integer|DateTime The time at which the URL should expire. This can be a Unix timestamp, a PHP DateTime object, or a string that can be evaluated by strtotime().
return string

getCdnUrl($filename)

Returns the CloundFront URL to an object.

Argument Type Description
$filename string
return string

getList($prefix = null, array $options = [])

Returns some or all (up to 1000] of the objects in a bucket.

Argument Type Description
$prefix string Limits the response to keys that begin with the specified prefix.
$options array Other parameters.
return Aws\ResultInterface See result syntax.

upload($filename, $source, $acl = null, array $options = [])

Upload a file, stream, or string to a bucket.

If the upload size exceeds the specified threshold, the upload will be performed using concurrent multipart uploads.

Argument Type Description
$filename string
$source mixed Object data to upload. Can be a Psr\Http\Message\StreamInterface, php stream resource, or a string of data to upload.
$acl string ACL to apply to the object.
$options array Options used to configure the upload process. See more.
return Aws\ResultInterface Returns the result of the upload.

uploadAsync($filename, $source, $concurrency = null, $partSize = null, $acl = null, array $options = [])

Upload a file, stream, or string to a bucket asynchronously.

Argument Type Description
$filename string
$source mixed Object data to upload. Can be a Psr\Http\Message\StreamInterface, php stream resource, or a string of data to upload.
$concurrency integer Maximum number of concurrent UploadPart operations allowed during the multipart upload. Default 5.
$partSize integer Part size, in bytes, to use when doing a multipart upload. This must between 5 MB and 5 GB, inclusive. Default 5242880 (512 MB).
$acl string ACL to apply to the object.
$options array Options used to configure the upload process. See more.
return GuzzleHttp\Promise\PromiseInterface Returns a promise that will be fulfilled with the result of the upload.

getClient()

Returns the S3Client object.

Argument Type Description
return Aws\S3\S3Client