• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Python SDK)
  4. Objects-Related APIs
  5. DELETE Object

DELETE Object

API Description

You can use this API to delete an object from a specified bucket.

Method Definition

ObsClient.deleteObject(bucketName, objectKey, versionId)

Request Parameter

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

objectKey

str

Mandatory

Object name

versionId

str

Optional

Version ID of the object to be deleted

Returned Result

Type

Description

GetResult

SDK common result object

GetResult.body Type

Description

DeleteObjectResponse

Response result of DELETE Object

Sample Code

try:
    resp = obsClient.deleteObject('bucketname', 'objectkey') 
          
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
        print('deleteMarker:', resp.body.deleteMarker) 
        print('versionId:', resp.body.versionId) 
    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())