DELETE Multiple Objects

You can perform this operation to batch delete multiple objects from a bucket.

Deleted objects cannot be restored. OBS deletes multiple objects simultaneously and returns the deletion result of each object.

The DELETE Multiple Objects operation supports two modes for response: verbose and quiet.

In verbose mode, the returned response includes the deletion result of each requested object in an XML file.

In quiet mode, the returned response includes only results of objects that failed to be deleted. The OBS uses verbose mode by default and you can specify quiet mode in the request body.

A DELETE Multiple Objects request must contain headers Content-MD5 and Content-Length to detect network errors.

Request Syntax

POST /?delete HTTP/1.1 
Host: bucketname.obs.cn-north-1.myhwclouds.com
Authorization: authorization
Content-MD5: MD5
Content-Length: length
 
<?xml version="1.0" encoding="UTF-8"?>  
<Delete>
    <Quiet>true</Quiet> 
    <Object>
        <Key>Key</Key>
        <VersionId>VersionId</VersionId>
    </Object> 
    <Object> 
        <Key>Key</Key>
    </Object>
</Delete>  

Request Parameters

This request contains no parameter.

Request Headers

This request uses common headers. For details, see Common Request Headers.

Request Elements

This request uses elements to specify the list of objects to be deleted in a batch. Table 1 describes the elements.

Table 1 Request elements

Element

Description

Required or Optional

Quiet

Indicates the element to enable quite mode for the request. If the element is specified, OBS returns only the list of objects that failed to be deleted.

This element is only valid when its value is true. Otherwise, OBS ignores it.

Type: Boolean

Optional

Delete

Indicates the list of objects to be deleted.

Type: XML

Required

Object

Indicates an object to be deleted.

Type: XML

Required

Key

Indicates the key of an object to be deleted.

Type: string

Required

VersionId

Indicates the version ID of an object to be deleted.

Type: string

Optional

NOTICE:

Request constraints:

This request can delete a maximum of 1000 objects at a time. If you send the request to delete more than 1000 objects, OBS returns an error response.

After receiving the request, OBS deletes objects simultaneously in a circular manner. During this process, OBS may encounter an internal error. For example, data inconsistency may occur because the metadata of an object still exists after the object's index data is deleted.

Response Syntax

HTTP/1.1 status_code
Date: date
Content-Type: application/xml
Content-Length: length  

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DeleteResult xmlns="http://obs.cn-north-1.myhwclouds.com/doc/2015-06-30/">
<Deleted>
    <Key>Key</Key>
</Deleted>
<Error>
    <Key>Key</Key>
    <Code>ErrorCode</Code>
    <Message>messagee</Message>
</Error>
</DeleteResult>

Response Headers

This response uses common headers. For details about common response headers, see Common Response Headers.

Response Elements

This response contains elements to return results of object deletion. Table 2 describes the elements.

Table 2 Response elements

Element

Description

Required or Optional

DeleteResult

Indicates the root node of batch deletion responses.

Type: container

Required

Deleted

Indicates the container element for a successful deletion.

Type: container

Required

Error

Indicates the container for a failed deletion.

Type: container

Required

Key

Indicates the key of a deleted object.

Type: string

Required

Code

Indicates the status code for a failed deletion.

Type: string

Required

Message

Indicates the error details about a failed deletion.

Type: String

Required

VersionId

Indicates the version ID of an object to be deleted.

Type: string

Optional

DeleteMarker

If this element is specified, true will be returned when you create or delete a deletion marker in the requested bucket with versioning enabled.

Type: Boolean

Optional

DeleteMarkerVersionId

Indicates the version ID of the deletion marker deleted or created by the request.

If the DELETE multiple objects request either creates or deletes a deletion marker, OBS returns this element in response with the version ID of the deletion marker. This element will be returned in either of the following cases:

  • You send a versionless DELETE multiple object request, that is, you specify only the object name but not the version ID. In this case, OBS creates a deletion marker and returns its version ID in the response.
  • You send a version DELETE multiple objects request, that is, you specify an object key and a version ID that identifies a deletion marker. In this case, OBS deletes a deletion marker and returns its version ID in the response.

Type: Boolean

Optional

Error Responses

1. If the resolution result of an XML request contains more than 1000 objects, OBS returns "400 Bad Request".

2. If the object key in an XML request is invalid (for example, containing more than 1024 characters), OBS returns "400 Bad Request".

3. If the request header does not contain Content-MD5, OBS returns "400 Bad Request".

For details about other error responses, see Table 1.

Registration