OSS_LIFECYCLE_EXPIRATION
OSS_LIFECYCLE_EXPIRATION = "Expiration"
Class OssClient
Object Storage Service(OSS)'s client class, which wraps all OSS APIs user could call to talk to OSS. Users could do operations on bucket, object, including MultipartUpload or setting ACL via an OSSClient instance. For more details, please check out the OSS API document:https://www.alibabacloud.com/help/doc-detail/31947.htm
__construct(string $accessKeyId, string $accessKeySecret, string $endpoint, bool $isCName = false, string $securityToken = NULL, string $requestProxy = NULL) : mixed
Constructor
There're a few different ways to create an OssClient object:
string | $accessKeyId | The AccessKeyId from OSS or STS |
string | $accessKeySecret | The AccessKeySecret from OSS or STS |
string | $endpoint | The domain name of the datacenter,For example: oss-cn-hangzhou.aliyuncs.com |
bool | $isCName | If this is the CName and binded in the bucket. |
string | $securityToken | from STS. |
string | $requestProxy |
deleteBucket(string $bucket, array $options = NULL) : null
Deletes bucket The deletion will not succeed if the bucket is not empty (either has objects or parts) To delete a bucket, all its objects and parts must be deleted first.
string | $bucket | |
array | $options |
putBucketAcl(string $bucket, string $acl, array $options = NULL) : null
Sets the bucket ACL
string | $bucket | bucket name |
string | $acl | access permissions, valid values are ['private', 'public-read', 'public-read-write'] |
array | $options | by default is empty |
putObjectAcl(string $bucket, string $object, string $acl, array $options = NULL) : null
Sets the object ACL
string | $bucket | bucket name |
string | $object | object name |
string | $acl | access permissions, valid values are ['default', 'private', 'public-read', 'public-read-write'] |
array | $options |
putBucketLogging(string $bucket, string $targetBucket, string $targetPrefix, array $options = NULL) : null
Sets the bycket logging config. Only owner can call this API.
string | $bucket | bucket name |
string | $targetBucket | The logging file's bucket |
string | $targetPrefix | The logging file's prefix |
array | $options | By default is empty. |
putBucketWebsite(string $bucket, \OSS\Model\WebsiteConfig $websiteConfig, array $options = NULL) : null
Sets the website config in bucket---that is could make the bucket as a static website once the CName is binded.
string | $bucket | bucket name |
\OSS\Model\WebsiteConfig | $websiteConfig | |
array | $options |
putBucketCors(string $bucket, \OSS\Model\CorsConfig $corsConfig, array $options = NULL) : null
Sets the cross-origin-resource-sharing (CORS) rule. It would overwrite the originl one.
string | $bucket | bucket name |
\OSS\Model\CorsConfig | $corsConfig | CORS config. Check out the details from OSS API document |
array | $options | array |
putBucketLiveChannel(string $bucket, mixed $channelName, \OSS\Model\LiveChannelConfig $channelConfig, array $options = NULL) : \OSS\Model\LiveChannelInfo
Creates a Live Channel under a bucket
string | $bucket | bucket name |
mixed | $channelName | |
\OSS\Model\LiveChannelConfig | $channelConfig | |
array | $options |
getLiveChannelInfo(string $bucket, mixed $channelName, array $options = NULL) : \OSS\GetLiveChannelInfo
Gets the LiveChannel information by the channel name
string | $bucket | bucket name |
mixed | $channelName | |
array | $options |
getLiveChannelHistory(string $bucket, mixed $channelName, array $options = NULL) : \OSS\GetLiveChannelHistory
Gets the LiveChannel pushing streaming record
string | $bucket | bucket name |
mixed | $channelName | |
array | $options |
postVodPlaylist(string $bucket, mixed $channelName, string $playlistName, array $setTime) : null
Creates a play list file for the LiveChannel
string | $bucket | bucket name |
mixed | $channelName | |
string | $playlistName | The playlist name, must end with ".m3u8". |
array | $setTime | startTime and EndTime in unix time. No more than 1 day. |
signRtmpUrl(string $bucket, mixed $channelName, mixed $timeout = 60, array $options = NULL) : \OSS\The
Generates the signed pushing streaming url
string | $bucket | bucket name |
mixed | $channelName | |
mixed | $timeout | |
array | $options |
signed pushing streaming url
generatePresignedRtmpUrl(string $bucket, string $channelName, int $expiration, array $options = NULL) : \OSS\The
Generates the signed pushing streaming url
string | $bucket | bucket name |
string | $channelName | channel name |
int | $expiration | expiration time of the Url, unix epoch, since 1970.1.1 00.00.00 UTC |
array | $options |
signed pushing streaming url
optionsObject(string $bucket, string $object, string $origin, string $request_method, string $request_headers, array $options = NULL) : array
Precheck the CORS request. Before sending a CORS request, a preflight request (OPTIONS) is sent with the specific origin.
HTTP METHOD and headers information are sent to OSS as well for evaluating if the CORS request is allowed.
Note: OSS could enable the CORS on the bucket by calling putBucketCors. Once CORS is enabled, the OSS could evaluate accordingto the preflight request.
string | $bucket | bucket name |
string | $object | object name |
string | $origin | the origin of the request |
string | $request_method | The actual HTTP method which will be used in CORS request |
string | $request_headers | The actual HTTP headers which will be used in CORS request |
array | $options |
putBucketLifecycle(string $bucket, \OSS\Model\LifecycleConfig $lifecycleConfig, array $options = NULL) : null
Sets the bucket's lifecycle config
string | $bucket | bucket name |
\OSS\Model\LifecycleConfig | $lifecycleConfig | LifecycleConfig instance |
array | $options |
putBucketReferer(string $bucket, \OSS\Model\RefererConfig $refererConfig, array $options = NULL) : \OSS\Http\ResponseCore
Sets a bucket's referer, which has a whitelist of referrer and specifies if empty referer is allowed.
Checks out API document for more details about "Bucket Referer"
string | $bucket | bucket name |
\OSS\Model\RefererConfig | $refererConfig | |
array | $options |
getBucketReferer(string $bucket, array $options = NULL) : \OSS\Model\RefererConfig
Gets the bucket's Referer Checks out API document for more details about "Bucket Referer"
string | $bucket | bucket name |
array | $options |
putBucketStorageCapacity(string $bucket, int $storageCapacity, array $options = NULL) : \OSS\Http\ResponseCore
Set the size of the bucket,the unit is GB When the capacity of the bucket is bigger than the set, it's forbidden to continue writing
string | $bucket | bucket name |
int | $storageCapacity | |
array | $options |
putBucketEncryption(string $bucket, \OSS\Model\ServerSideEncryptionConfig $sseConfig, array $options = NULL) : null
Sets the bucket's encryption
string | $bucket | bucket name |
\OSS\Model\ServerSideEncryptionConfig | $sseConfig | |
array | $options |
putBucketRequestPayment(string $bucket, string $payer, array $options = NULL) : \OSS\Http\ResponseCore
Set the request playment of the bucket, Can be BucketOwner and Requester
string | $bucket | bucket name |
string | $payer | |
array | $options |
deleteBucketTags(string $bucket, \OSS\tag[] $tags = NULL, array $options = NULL) : null
Deletes the bucket's tags If want to delete specified tags for a bucket, please set the $tags
string | $bucket | bucket name |
\OSS\tag[] | $tags | (optional) |
array | $options |
putBucketVersioning(string $bucket, string $status, array $options = NULL) : \OSS\Http\ResponseCore
Set the versioning of the bucket, Can be BucketOwner and Requester
string | $bucket | bucket name |
string | $status | |
array | $options |
listObjects(string $bucket, array $options = NULL) : \OSS\Model\ObjectListInfo
Lists the bucket's object list (in ObjectListInfo)
string | $bucket | |
array | $options | are defined below: $options = array( 'max-keys' => specifies max object count to return. By default is 100 and max value could be 1000. 'prefix' => specifies the key prefix the returned objects must have. Note that the returned keys still contain the prefix. 'delimiter' => The delimiter of object name for grouping object. When it's specified, listObjects will differeniate the object and folder. And it will return subfolder's objects. 'marker' => The key of returned object must be greater than the 'marker'. ) Prefix and marker are for filtering and paging. Their length must be less than 256 bytes |
listObjectVersions(string $bucket, array $options = NULL) : \OSS\Model\ObjectListInfo
Lists the bucket's object with version information (in ObjectListInfo)
string | $bucket | |
array | $options | are defined below: $options = array( 'max-keys' => specifies max object count to return. By default is 100 and max value could be 1000. 'prefix' => specifies the key prefix the returned objects must have. Note that the returned keys still contain the prefix. 'delimiter' => The delimiter of object name for grouping object. When it's specified, listObjectVersions will differeniate the object and folder. And it will return subfolder's objects. 'key-marker' => The key of returned object must be greater than the 'key-marker'. 'version-id-marker' => The version id of returned object must be greater than the 'version-id-marker'. ) Prefix and marker are for filtering and paging. Their length must be less than 256 bytes |
createObjectDir(string $bucket, string $object, array $options = NULL) : null
Creates a virtual 'folder' in OSS. The name should not end with '/' because the method will append the name with a '/' anyway.
Internal use only.
string | $bucket | bucket name |
string | $object | object name |
array | $options |
appendObject(string $bucket, string $object, string $content, mixed $position, array $options = NULL) : int
Append the object with the content at the specified position.
The specified position is typically the lengh of the current file.
string | $bucket | bucket name |
string | $object | objcet name |
string | $content | content to append |
mixed | $position | |
array | $options |
next append position
appendFile(string $bucket, string $object, string $file, mixed $position, array $options = NULL) : int
Append the object with a local file
string | $bucket | bucket name |
string | $object | object name |
string | $file | The local file path to append with |
mixed | $position | |
array | $options |
next append position
copyObject(string $fromBucket, string $fromObject, string $toBucket, string $toObject, array $options = NULL) : null
Copy from an existing OSS object to another OSS object. If the target object exists already, it will be overwritten.
string | $fromBucket | Source bucket name |
string | $fromObject | Source object name |
string | $toBucket | Target bucket name |
string | $toObject | Target object name |
array | $options |
getSimplifiedObjectMeta(string $bucket, string $object, string $options = NULL) : array
Gets the simplified metadata of a object.
Simplified metadata includes ETag, Size, LastModified.
string | $bucket | bucket name |
string | $object | object name |
string | $options | Checks out the SDK document for the detail |
deleteObjectVersions(string $bucket, array $objects, array $options = null) : \OSS\Http\ResponseCore
Deletes multiple objects with version id in a bucket
string | $bucket | bucket name |
array | $objects | DeleteObjectInfo list |
array | $options |
getObject(string $bucket, string $object, array $options = NULL) : string
Gets Object content
string | $bucket | bucket name |
string | $object | object name |
array | $options | It must contain ALIOSS::OSS_FILE_DOWNLOAD. And ALIOSS::OSS_RANGE is optional and empty means to download the whole file. |
doesObjectExist(string $bucket, string $object, array $options = NULL) : bool
Checks if the object exists It's implemented by getObjectMeta().
string | $bucket | bucket name |
string | $object | object name |
array | $options |
True:object exists; False:object does not exist
restoreObject(string $bucket, string $object, mixed $options = NULL) : null
Object reading for Archive type Use Restore to enable the server to perform the thawing task
string | $bucket | bucket name |
string | $object | object name |
mixed | $options |
putObjectTagging(string $bucket, string $object, \OSS\Model\TaggingConfig $taggingConfig, mixed $options = NULL) : null
Sets the object tagging
string | $bucket | bucket name |
string | $object | object name |
\OSS\Model\TaggingConfig | $taggingConfig | |
mixed | $options |
generateMultiuploadParts(int $file_size, int $partSize = 5242880) : array
Computes the parts count, size and start position according to the file size and the part size.
It must be only called by upload_Part().
int | $file_size | File size |
int | $partSize | part大小,part size. Default is 5MB |
An array contains key-value pairs--the key is seekTo
and value is length
.
initiateMultipartUpload(string $bucket, string $object, array $options = NULL) : string
Initialize a multi-part upload
string | $bucket | bucket name |
string | $object | object name |
array | $options | Key-Value array |
returns uploadid
uploadPart(string $bucket, string $object, string $uploadId, array $options = null) : string
Upload a part in a multiparts upload.
string | $bucket | bucket name |
string | $object | object name |
string | $uploadId | |
array | $options | Key-Value array |
eTag
listParts(string $bucket, string $object, string $uploadId, array $options = null) : \OSS\Model\ListPartsInfo
Gets the uploaded parts.
string | $bucket | bucket name |
string | $object | object name |
string | $uploadId | uploadId |
array | $options | Key-Value array |
abortMultipartUpload(string $bucket, string $object, string $uploadId, array $options = NULL) : null
Abort a multiparts upload
string | $bucket | bucket name |
string | $object | object name |
string | $uploadId | uploadId |
array | $options | Key-Value name |
completeMultipartUpload(string $bucket, string $object, string $uploadId, array $listParts, array $options = NULL) : null
Completes a multiparts upload, after all parts are uploaded.
string | $bucket | bucket name |
string | $object | object name |
string | $uploadId | uploadId |
array | $listParts | array( array("PartNumber"=> int, "ETag"=>string)) |
array | $options | Key-Value array |
listMultipartUploads(string $bucket, array $options = null) : \OSS\Model\ListMultipartUploadInfo
Lists all ongoing multipart upload events, which means all initialized but not completed or aborted multipart uploads.
string | $bucket | bucket |
array | $options | key-value array--expected keys are 'delimiter', 'key-marker', 'max-uploads', 'prefix', 'upload-id-marker' |
uploadPartCopy(string $fromBucket, string $fromObject, string $toBucket, string $toObject, int $partNumber, string $uploadId, array $options = NULL) : null
Copy an existing file as a part
string | $fromBucket | source bucket name |
string | $fromObject | source object name |
string | $toBucket | target bucket name |
string | $toObject | target object name |
int | $partNumber | Part number |
string | $uploadId | Upload Id |
array | $options | Key-Value array---it should have 'start' or 'end' key to specify the range of the source object to copy. If it's not specifed, the whole object is copied. |
multiuploadFile(string $bucket, string $object, string $file, array $options = null) : null
A higher level API for uploading a file with multipart upload. It consists of initialization, parts upload and completion.
string | $bucket | bucket name |
string | $object | object name |
string | $file | The local file to upload |
array | $options | Key-Value array |
uploadDir(string $bucket, string $prefix, string $localDirectory, string $exclude = '.|..|.svn|.git', bool $recursive = false, bool $checkMd5 = true) : array
Uploads the local directory to the specified bucket into specified folder (prefix)
string | $bucket | bucket name |
string | $prefix | The object key prefix. Typically it's folder name. The name should not end with '/' as the API appends it automatically. |
string | $localDirectory | The local directory to upload |
string | $exclude | To excluded directories |
bool | $recursive | Recursive flag. True: Recursively upload all datas under the local directory; False: only upload first layer's files. |
bool | $checkMd5 |
Returns two list: array("succeededList" => array("object"), "failedList" => array("object"=>"errorMessage"))
signUrl(string $bucket, string $object, int $timeout = 60, string $method = self::OSS_HTTP_GET, array $options = NULL) : string
Sign URL with specified expiration time in seconds (timeout) and HTTP method.
The signed URL could be used to access the object directly.
string | $bucket | |
string | $object | |
int | $timeout | expiration time in seconds. |
string | $method | |
array | $options | Key-Value array |
generatePresignedUrl(string $bucket, string $object, int $expiration, string $method = self::OSS_HTTP_GET, array $options = NULL) : string
Sign URL with specified expiration time in seconds and HTTP method.
The signed URL could be used to access the object directly.
string | $bucket | |
string | $object | |
int | $expiration | expiration time of the Url, unix epoch, since 1970.1.1 00.00.00 UTC |
string | $method | |
array | $options | Key-Value array |
generateHostname( $bucket) : string
Gets the host name for the current request.
It could be either a third level domain (prefixed by bucket name) or second level domain if it's CName or IP
$bucket |
The host name without the protocol scheem (e.g. https://)
checkEndpoint(string $endpoint, bool $isCName) : string
Checks endpoint type and returns the endpoint without the protocol schema.
Figures out the domain's type (ip, cname or private/public domain).
string | $endpoint | |
bool | $isCName |
The domain name without the protocol schema.