API Reference

This page lists the primary methods available in the OSS\OssClient class.

Bucket Methods

Method Description
listBuckets($options) Lists all buckets in the account.
createBucket($bucket, $acl, $options) Creates a new bucket.
deleteBucket($bucket, $options) Deletes an empty bucket.
doesBucketExist($bucket) Checks if a bucket exists.
getBucketAcl($bucket) Gets the bucket ACL.
putBucketAcl($bucket, $acl) Sets the bucket ACL.
getBucketLocation($bucket) Gets the datacenter region.
getBucketMeta($bucket) Gets bucket metadata.
getBucketStat($bucket) Gets storage statistics.

Object Methods

Method Description
putObject($bucket, $obj, $content, $opt) Simple upload from memory.
uploadFile($bucket, $obj, $file, $opt) Upload from a local file.
uploadStream($bucket, $obj, $handle, $opt) Upload from a resource handle.
getObject($bucket, $obj, $opt) Downloads an object.
deleteObject($bucket, $obj, $opt) Deletes a single object.
deleteObjects($bucket, $list, $opt) Batch deletes objects.
copyObject($srcB, $srcK, $dstB, $dstK) Copies an object.
doesObjectExist($bucket, $obj) Checks if an object exists.
getObjectMeta($bucket, $obj) Gets object headers.

Multipart Methods

Method Description
multiuploadFile($bucket, $obj, $file, $opt) High-level multipart upload.
initiateMultipartUpload($bucket, $obj) Starts a multipart event.
uploadPart($bucket, $obj, $upId, $opt) Uploads a single part.
completeMultipartUpload($bucket, $obj, $upId, $parts) Finalizes the upload.
listMultipartUploads($bucket, $opt) Lists active multipart events.

Security Methods

Method Description
signUrl($bucket, $obj, $timeout, $method) Generates a pre-signed URL.
signRtmpUrl($bucket, $chan, $timeout) Generates a signed RTMP publish URL.

Exception Handling

All methods throw OSS\Core\OssException. You can catch this to inspect the error code and request ID.

try {
    // ... operation
} catch (OssException $e) {
    echo "Error Code: " . $e->getErrorCode();
    echo "Request ID: " . $e->getRequestId();
}