-
API Reference
- Overview
- Initialization
- Predefined Constants
-
Bucket-Related APIs
- PUT Bucket
- GET Buckets
- HEAD Bucket
- DELETE Bucket
- GET Objects
- GET Object versions
- List Multipart uploads
- Obtain Bucket Metadata
- GET Bucket location
- GET Bucket storageinfo
- PUT Bucket quota
- GET Bucket quota
- Set Bucket storagePolicy
- GET Bucket storagePolicy
- PUT Bucket acl
- GET Bucket acl
- PUT Bucket logging
- GET Bucket logging
- PUT Bucket policy
- GET Bucket policy
- DELETE Bucket policy
- PUT Bucket lifecycle
- GET Bucket lifecycle
- DELETE Bucket lifecycle
- PUT Bucket website
- GET Bucket website
- DELETE Bucket website
- PUT Bucket versioning
- GET Bucket versioning
- PUT Bucket cors
- GET Bucket cors
- DELETE Bucket cors
- PUT Bucket tagging
- GET Bucket tagging
- DELETE Bucket tagging
- Objects-Related APIs
- Other APIs
- Change History
- General Reference
Show all
Copied.
Asynchronous Method Call
API Description
All bucket- and object-related APIs provided by OBS PHP SDK can be called by asynchronous methods whose names end with Async (such as ObsClient->putObjectAsync if the synchronous method is named ObsClient->putObject). The returned result will be output to a callback function. A callback function contains an SDK custom exception and an SDK common result object in sequence. If the SDK custom exception is not null, the operation fails. Otherwise, the operation succeeds.
Sample Code
$promise = $obsClient->putObjectAsync ( [ 'Bucket' => 'bucketname', 'Key' => 'objectkey', 'Body' => 'Hello OBS' ], function ($obsException, $resp) { if ($obsException === null) { printf ( "RequestId:%s\n", $resp ['RequestId'] ); } else { printf ( "ExceptionCode:%s\n", $obsException->getExceptionCode () ); printf ( "ExceptionMessage:%s\n", $obsException->getExceptionMessage () ); } } ); $promise->wait ();
A result object (GuzzleHttp\Promise\Promise) will be returned upon an asynchronous method call. You need to call the wait method of the object to wait until the asynchronous method call is complete.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot