SDK Common Results (SDK for Python)
Function
Each time an ObsClient related API is called (excluding ObsClient.createSignedUrl and ObsClient.createPostSignature), an SDK common result object will be returned. You can obtain the HTTP status code from this object to check whether the operation is successful.
Parameter Description
Parameter |
Type |
Description |
---|---|---|
status |
int |
Explanation: HTTP status code Value range: A status code is a group of digits ranging from 2xx (indicating successes) to 4xx or 5xx (indicating errors). It indicates the status of a response. For more information, see Status Code. Default value: None |
reason |
str |
Explanation: Reason description. Default value: None |
errorCode |
str |
Explanation: Error code returned by the OBS server. If the value of status is less than 300, this parameter is left blank. Default value: None |
errorMessage |
str |
Explanation: Error message returned by the OBS server. If the value of status is less than 300, this parameter is left blank. Default value: None |
requestId |
str |
Explanation: Request ID returned by the OBS server Default value: None |
indicator |
str |
Explanation: Error indicator returned by the OBS server. Default value: None |
hostId |
str |
Explanation: Requested server ID. If the value of status is less than 300, this parameter is left blank. Default value: None |
resource |
str |
Explanation: Error source (a bucket or an object). If the value of status is less than 300, this parameter is left blank. Default value: None |
header |
list |
Explanation: Response header list, composed of tuples. Each tuple consists of two elements, respectively corresponding to the key and value of a response header. Default value: None |
body |
object |
Explanation: Result content returned after the operation is successful. If the value of status is larger than 300, the value of body is null. The value varies with the API being called. For details, see Bucket-Related APIs (SDK for Python) and Object-Related APIs (SDK for Python). Default value: None |
{ 'status': 200, 'reason': 'OK', 'body': { ...The details are omitted here. }, 'requestId': '000001************B5512', 'header': [...The header is omitted.] }
Code Examples
try: resp = obsClient.getObject('bucketname', 'objectname', loadStreamInMemory=True) if resp.status < 300: print('requestId:', resp.requestId) # Obtain the object content. print('buffer:', resp.body.buffer) print('size:', resp.body.size) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage) except: import traceback print(traceback.format_exc())
In a binary download, if loadStreamInMemory is set to True, the object content is contained in the body.buffer parameter in the returned result.
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