Deleting Objects
Functions
This operation can be used to batch delete some objects in a bucket. The deletion cannot be undone. After the operation is implemented, the returned information contains the implementation result of each object in the specified bucket. OBS deletes the objects synchronously. The deletion result of each object is returned to the request user.
Objects in batches can be deleted in verbose or quiet mode. With verbose mode, OBS returns results of successful and failed deletion in an XML response; with quiet mode, OBS only returns results of failed deletion in an XML response. OBS uses the verbose mode by default and you can specify the quiet mode in the request body.
For batch deletion, the request header must contain Content-SHA256 and Content-Length, so that the message body can be identified if network transmission error is detected at the server side.
Request Syntax
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
POST /?delete HTTP/1.1 Host: bucketname.obs.region.myhuaweicloud.eu Date: date Authorization: authorization Content-SHA256: SHA256 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 involves no parameters.
Request Headers
This request uses common headers. For details, see Table 3.
Request Elements
This request uses elements to specify the list of objects to be deleted in a batch. Table 1 describes the elements.
Element |
Description |
Mandatory |
---|---|---|
Quiet |
Specifies the quiet mode. With the quiet mode, OBS only returns the list of objects that failed to be deleted. This element is valid when set to true. Otherwise, OBS ignores it. Type: boolean |
No |
Delete |
List of objects to be deleted Type: XML |
Yes |
Object |
Names of objects to be deleted Type: XML |
Yes |
Key |
Key of the object to be deleted. Type: string |
Yes |
VersionId |
Version ID of the object to be deleted Type: string |
No |
A maximum of 1,000 objects can be deleted at a time. If you send a request for deleting more than 1,000 objects, OBS returns an error message.
After concurrent tasks are assigned, OBS may encounter an internal error during cyclic deletion of multiple objects. In that case, the metadata still exists when the object index data is deleted, which means data inconsistency.
Response Syntax
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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.region.myhuaweicloud.eu/doc/2015-06-30/"> <Deleted> <Key>Key</Key> </Deleted> <Error> <Key>Key</Key> <Code>ErrorCode</Code> <Message>Message</Message> </Error> </DeleteResult> |
Response Headers
The response to the request uses common headers. For details, see Table 1.
Response Elements
This response uses elements to return results of deleted objects in a batch. Table 2 describes the elements.
Element |
Description |
---|---|
DeleteResult |
Root node of batch deletion responses Type: container |
Deleted |
Container for results of successful deletion Type: container |
Error |
Container for results of failed deletion Type: container |
Key |
Object names in a deletion result Type: string |
Code |
Error code of a deletion failure Type: string |
Message |
Error message of a deletion failure Type: string |
VersionId |
Version IDs of objects to be deleted Type: string |
DeleteMarker |
If this element is specified, true will be returned when you create or delete a delete marker in a bucket with versioning enabled. Type: boolean |
DeleteMarkerVersionId |
Indicates the version ID of the delete marker deleted or created by the request. If you create or delete a delete marker in a bucket with versioning enabled, OBS returns this element in the response. This element will be returned in either of the following cases:
Type: boolean |
Error Responses
1. If the resolution result of an XML request contains more than 1,000 objects, OBS returns 400 Bad Request.
2. If the object key in an XML request is invalid (for example, containing more than 1,024 characters after being encoded with UTF-8), OBS returns 400 Bad Request.
3. If the request header does not contain Content-SHA256, OBS returns 400 Bad Request.
Other errors are included in Table 2.
Sample Request
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
POST /test333?delete HTTP/1.1 User-Agent: curl/7.29.0 Host: 127.0.0.1 Accept: */* Date: WED, 01 Jul 2015 04:34:21 GMT Authorization: OBS H4IPJX0TQTHTHEBQQCEC:8sjZWJlWmYmYnK5JqXaFFQ+vHEg= Content-SHA256: ogX9qClMrVJUBiUSIKDFM0qO41jJM0I5SCN55/OtMyI= Content-Length: 188 <?xml version="1.0" encoding="utf-8"?> <Delete> <Quiet>true</Quiet> <Object> <Key>obja02</Key> </Object> <Object> <Key>obja02</Key> </Object> </Delete> |
Sample Response
1 2 3 4 5 6 7 8 9 10 |
HTTP/1.1 200 OK Server: OBS x-obs-request-id: 8DF400000163D3FE4CE80340D30B0542 x-obs-id-2: 32AAAQAAEAABAAAQAAEAABAAAQAAEAABCRhY0FBWRm6qjOE1ACBZwS+0KYlPBq0f Content-Type: application/xml Date: WED, 01 Jul 2015 04:34:21 GMT Content-Length: 120 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <DeleteResult xmlns="http://obs.eu-west-101.myhuaweicloud.eu/doc/2015-06-30/"/> |
Sample Request: Specifying versionId to Delete Multiple Delete Markers
POST /?delete HTTP/1.1 Authorization: OBS H4IPJX0TQTHTHEBQQCEC:iqSPeUBl66PwXDApxjRKk6hlcN4= User-Agent: curl/7.29.0 Host: examplebucket.obs.region.myhuaweicloud.com Date: WED, 01 Jul 2015 02:37:22 GMT Content-Type: application/xml Content-MD5: Y4+cxEPU7U9sgVFpRbdtUQ== <Delete> <Object> <Key>object1</Key> <VersionId>G001118A646F2ACEFFFFD24530CFB5D8</VersionId> </Object> <Object> <Key>object2</Key> <VersionId>G001118A646F2ACEFFFFD24530CFB5D9</VersionId> </Object> </Delete>
Sample Response: Specifying versionId to Delete Multiple Delete Markers
x-obs-id-2: 32AAAUgAIAABAAAQAAEAABAAAQAAEAABCS3WJqDiMsxgGHKQrlqST9veFKpDgE50 x-obs-request-id: 0000018A4997390DD306CCDA0DEC814F Server: OBS Date: WED, 01 Jul 2015 02:37:22 GMT Content-Length: 545 Content-Type: application/xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <DeleteResult xmlns="http://obs.myhwclouds.com/doc/2015-06-30/"> <Deleted> <Key>object1</Key> <VersionId>G001118A646F2ACEFFFFD24530CFB5D9</VersionId> <DeleteMarker>true</DeleteMarker> <DeleteMarkerVersionId>G001118A646F2ACEFFFFD24530CFB5D9</DeleteMarkerVersionId> </Deleted> <Deleted> <Key>object2</Key> <VersionId>G001118A646F2ACEFFFFD24530CFB5D8</VersionId> <DeleteMarker>true</DeleteMarker> <DeleteMarkerVersionId>G001118A646F2ACEFFFFD24530CFB5D8</DeleteMarkerVersionId> </Deleted> </DeleteResult>
Sample Request: Sending a Request in Wrong XML Format
POST /?delete HTTP/1.1 Authorization: OBS H4IPJX0TQTHTHEBQQCEC:iqSPeUBl66PwXDApxjRKk6hlcN4= User-Agent: curl/7.29.0 Host: examplebucket.obs.region.myhuaweicloud.com Date: WED, 01 Jul 2015 02:37:22 GMT Content-Type: application/xml Content-MD5: Y4+cxEPU7U9sgVFpRbdtUQ== <Delete> <Quiet>true</Quiet> <Object> <Key>object1</Key> </Object> <Object> <Key>object2</Key> </Object>
Sample Response: Sending a Request in Wrong XML Format
x-obs-id-2: 32AAAUgAIAABAAAQAAEAABAAAQAAEAABCS3WJqDiMsxgGHKQrlqST9veFKpDgE50 x-obs-request-id: 0000018A4997390DD306CCDA0DEC814F Server: OBS Date: WED, 01 Jul 2015 02:37:22 GMT Content-Length: 545 Content-Type: application/xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Error> <Code>MalformedXML</Code> <Message>The XML you provided was not well-formed or did not validate against our published schema</Message> <RequestId>0000018A647F5559D385F15A331DF49B</RequestId> <HostId>buloGEikvQr7lmiZEtHxD9nO2owRwBRGQfbap4E9MFTp1YJJV66rkJNLl7cs3Zlz</HostId> </Error>
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.