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.com 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.
Parameter |
Mandatory (Yes/No) |
Type |
Description |
---|---|---|---|
Delete |
Yes |
XML |
Definition: List of objects to be deleted. Delete is the parent node of Object and Quiet. Constraints: None Range: For details, see Table 2. Default value: None |
EncodingType |
No |
String |
Definition: The encoding type of the object name to be deleted and the object name in the response. If an object name contains control characters that are not supported by the XML 1.0 standard, you can use this parameter to specify the encoding type of the object name. Constraints: Only the URL encoding type is supported. Range: url Default value: None |
Parameter |
Mandatory (Yes/No) |
Type |
Description |
---|---|---|---|
Quiet |
No |
Boolean |
Definition: Whether to use the quiet mode. If this parameter is set to True, only the results of objects that fail to be deleted are returned. Constraints: If this parameter is not set, the default value False is used. If the value is False, the system ignores the value. Range:
Default value: False |
Object |
Yes |
XML |
Definition: Object to be deleted. Object is the parent node of Key and VersionId. Constraints: None Range: For details, see Table 3. Default value: None |
Parameter |
Mandatory (Yes/No) |
Type |
Description |
---|---|---|---|
Key |
Yes |
String |
Definition: Name of the object to be deleted. Constraints: If EncodingType is specified, the object name must be encoded as specified. Range: 1 to 1,024 characters Default value: None |
VersionId |
No |
String |
Definition: Version ID of the object to be deleted. For details about how to obtain an object version, see Listing Objects in a Bucket. Constraints: None Range: The value must contain 32 characters. Default value: None |
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.com/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 4 describes the elements.
Parameter |
Type |
Description |
---|---|---|
DeleteResult |
Container |
Definition: Root node of the response message. DeleteResult is the parent node of Deleted, Error, and EncodingType. Range: For details, see Table 5. |
Parameter |
Type |
Description |
---|---|---|
Deleted |
Container |
Definition: Container for successful deletion results. Deleted is the parent node of Key, VersionId, DeleteMarker, and DeleteMarkerVersionId. Range: For details, see Table 6. |
Error |
Container |
Definition: Container for the deletion failure result. Error is the parent node of Key, VersionId, Code, and Message. Range: For details, see Table 7. |
EncodingType |
String |
Definition: The type of encoding for the object name in the response. If this parameter is set in the request, the object name in the response will be encoded. Range: url |
Parameter |
Type |
Description |
---|---|---|
Key |
String |
Definition: Object name in each deletion result Range: 1 to 1,024 characters |
VersionId |
String |
Definition: Version ID of the deleted object Range: The value must contain 32 characters. |
DeleteMarker |
Boolean |
Definition: If this element is specified, true will be returned when you create or delete a delete marker in a bucket with versioning enabled. When versioning is enabled for a bucket, a delete request that does not specify a version ID cannot permanently delete the object. Instead, OBS creates a delete marker with a unique version ID. When versioning is suspended for a bucket, a delete request that does not specify a version ID deletes the object whose version ID is null and creates a delete marker with a version ID of null. For more information, see Deleting Objects from an OBS Bucket. Range: true |
DeleteMarkerVersionId |
String |
Definition: Version ID of a delete marker to create or delete. 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:
For more information, see Deleting Objects from an OBS Bucket. Range: The value must contain 32 characters. |
Parameter |
Type |
Description |
---|---|---|
Key |
String |
Definition: Object name in each deletion result Range: 1 to 1,024 characters |
Code |
String |
Definition: Error code of a deletion failure Range: None |
Message |
String |
Definition: Error message of a deletion failure Range: None |
VersionId |
String |
Definition: Version ID of the deleted object Range: The value must contain 32 characters. |
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.ap-southeast-1.myhuaweicloud.com/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.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot