tencent cloud

Cloud Object Storage

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Overview
Features
Use Cases
Strengths
Concepts
Regions and Access Endpoints
Specifications and Limits
Service Regions and Service Providers
Billing
Billing Overview
Billing Method
Billable Items
Free Tier
Billing Examples
Viewing and Downloading Bill
Payment Overdue
FAQs
Getting Started
Console
Getting Started with COSBrowser
User Guide
Creating Request
Bucket
Object
Data Management
Batch Operation
Global Acceleration
Monitoring and Alarms
Operations Center
Data Processing
Content Moderation
Smart Toolbox
Data Processing Workflow
Application Integration
User Tools
Tool Overview
Installation and Configuration of Environment
COSBrowser
COSCLI (Beta)
COSCMD
COS Migration
FTP Server
Hadoop
COSDistCp
HDFS TO COS
GooseFS-Lite
Online Tools
Diagnostic Tool
Use Cases
Overview
Access Control and Permission Management
Performance Optimization
Accessing COS with AWS S3 SDK
Data Disaster Recovery and Backup
Domain Name Management Practice
Image Processing
Audio/Video Practices
Workflow
Direct Data Upload
Content Moderation
Data Security
Data Verification
Big Data Practice
COS Cost Optimization Solutions
Using COS in the Third-party Applications
Migration Guide
Migrating Local Data to COS
Migrating Data from Third-Party Cloud Storage Service to COS
Migrating Data from URL to COS
Migrating Data Within COS
Migrating Data Between HDFS and COS
Data Lake Storage
Cloud Native Datalake Storage
Metadata Accelerator
GooseFS
Data Processing
Data Processing Overview
Image Processing
Media Processing
Content Moderation
File Processing Service
File Preview
Troubleshooting
Obtaining RequestId
Slow Upload over Public Network
403 Error for COS Access
Resource Access Error
POST Object Common Exceptions
API Documentation
Introduction
Common Request Headers
Common Response Headers
Error Codes
Request Signature
Action List
Service APIs
Bucket APIs
Object APIs
Batch Operation APIs
Data Processing APIs
Job and Workflow
Content Moderation APIs
Cloud Antivirus API
SDK Documentation
SDK Overview
Preparations
Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Flutter SDK
Go SDK
iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
React Native SDK
Mini Program SDK
Error Codes
Harmony SDK
Endpoint SDK Quality Optimization
Security and Compliance
Data Disaster Recovery
Data Security
Cloud Access Management
FAQs
Popular Questions
General
Billing
Domain Name Compliance Issues
Bucket Configuration
Domain Names and CDN
Object Operations
Logging and Monitoring
Permission Management
Data Processing
Data Security
Pre-signed URL Issues
SDKs
Tools
APIs
Agreements
Service Level Agreement
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

DELETE Multiple Objects

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2025-09-09 17:20:19

Overview

This API is used to delete multiple objects (up to 1,000) from a bucket in a single request. COS provides the following two response modes:
Quiet: returns only information about objects that failed to delete and the error messages.
Verbose: returns the deletion results of each object.
To call this API, you need to have permission to write to the bucket.


Authorization Description

In anonymous access scenarios, the action in the authorization policy needs to be set to ["name/cos:DeleteObject","name/cos:DeleteMultipleObjects"]. In non-anonymous scenarios, each deleted object will be checked individually to see if the current account has the cos:DeleteObject permission. View all actions.

Versioning

If versioning is enabled, you can specify a version ID for each object to delete so that these objects/delete markers of the specified versions can be deleted permanently. If no version ID is specified, a new delete marker will be created for the object.
If a delete marker is created or deleted in this request, the <DeleteMarker>true</DeleteMarker> and <DeleteMarkerVersionId> nodes will be returned for this object.
If an object of a specified version (including the delete marker version) is deleted permanently in this request, the <VersionId> node will be returned, indicating the version ID that is deleted in this request.

Request

Sample request

POST /?delete HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: GMT Date
Content-Type: application/xml
Content-Length: Content Length
Content-MD5: MD5
Authorization: Auth String

[Request Body]
Note:
Host:<BucketName-APPID>.cos.<Region>.myqcloud.com, where <BucketName-APPID> is the bucket name followed by the APPID, such as examplebucket-1250000000 (see Bucket Overview > Basic Information and Bucket Overview > Bucket Naming Conventions), and <Region> is a COS region (see Regions and Access Endpoints).
Authorization: Auth String (See Request Signature for details.)

Request parameters

This API has no request parameter.

Request headers

This API only uses Common Request Headers.

Request body

The request body contains application/xml data that includes information about the objects to delete.
<Delete>
<Quiet>boolean</Quiet>
<Object>
<Key>string</Key>
</Object>
<Object>
<Key>string</Key>
<VersionId>string</VersionId>
</Object>
</Delete>
The nodes are described as follows:
Node Name (Keyword)
Parent Node
Description
Type
Required
Delete
None
Stores information about the DELETE Multiple Objects request.
Container
Yes
Content of Delete:
Node Name (Keyword)
Parent Node
Description
Type
Required
Quiet
Delete
Whether to use the Quiet mode for the response
true: yes (returns only information about objects that failed to delete and the error messages)
false (default): no (uses the Verbose mode instead, returning the deletion results of all objects)
Note:
When the specified key is empty or does not exist, COS itself will not return an error message.
boolean
Yes
Object
Delete
Information about a single object to delete
Container
Yes
Content of Object:
Node Name (Keyword)
Parent Node
Description
Type
Required
Key
Delete.Object
Key of the object to delete (The key does not need to start with a /)
string
Yes
VersionId
Delete.Object
Version ID of the object to delete (if versioning is enabled). If versioning is not enabled, or you want to create a delete marker with versioning enabled, you don’t need to specify this node.
string
Yes

Response

Response headers

This API only returns Common Response Headers.

Response body

application/xml data that contains the deletion results will be returned for a successful request.
<DeleteResult>
<Deleted>
<Key>string</Key>
<DeleteMarker>boolean</DeleteMarker>
<DeleteMarkerVersionId>string</DeleteMarkerVersionId>
</Deleted>
<Deleted>
<Key>string</Key>
<VersionId>string</VersionId>
</Deleted>
<Deleted>
<Key>string</Key>
<DeleteMarker>boolean</DeleteMarker>
<DeleteMarkerVersionId>string</DeleteMarkerVersionId>
<VersionId>string</VersionId>
</Deleted>
<Error>
<Key>string</Key>
<VersionId>string</VersionId>
<Code>string</Code>
<Message>string</Message>
</Error>
</DeleteResult>
The nodes are described as follows:
Node Name (Keyword)
Parent Node
Description
Type
DeleteResult
None
Stores the results of DELETE Multiple Objects
Container
Content of DeleteResult:
Node Name (Keyword)
Parent Node
Description
Type
Deleted
DeleteResult
An object entry that is successfully deleted. This node is returned only in Verbose mode.
Container
Error
DeleteResult
An object entry that failed to delete
Container
Content of Deleted:
Node Name (Keyword)
Parent Node
Description
Type
Key
DeleteResult.Deleted
Key of the object that is successfully deleted
string
DeleteMarker
DeleteResult.Deleted
Fixed to true. This node is returned when a delete marker is created or deleted for an object.
boolean
DeleteMarkerVersionId
DeleteResult.Deleted
ID of the delete marker that is created or deleted. This node is returned only when a delete marker is created or deleted for an object.
string
VersionId
DeleteResult.Deleted
Version ID of the object that is successfully deleted. This node is returned only when a version ID is specified in the request.
string
Content of Error:
Node Name (Keyword)
Parent Node
Description
Type
Key
DeleteResult.Error
Key of the object that failed to delete
string
VersionId
DeleteResult.Error
Version ID of the object that failed to delete. This node is returned only when a version ID is specified in the request.
string
Code
DeleteResult.Error
Error code for the deletion failure. The error code can be used to locate the error conditions and scenario.
string
Message
DeleteResult.Error
Error message for the deletion failure
string

Error codes

This API returns common error responses and error codes. For more information, please see Error Codes.

Sample

Sample 1: simple use case

Request

POST /?delete HTTP/1.1
Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.com
Date: Tue, 20 Aug 2019 11:59:35 GMT
Content-Type: application/xml
Content-Length: 158
Content-MD5: zUd/xgzNGDrqJMJUOWV2AQ==
Authorization: q-sign-algorithm=sha1&q-ak=************************************&q-sign-time=1566302375;1566309575&q-key-time=1566302375;1566309575&q-header-list=content-length;content-md5;content-type;date;host&q-url-param-list=delete&q-signature=****************************************
Connection: close

<Delete>
<Quiet>false</Quiet>
<Object>
<Key>example-object-1.jpg</Key>
</Object>
<Object>
<Key>example-object-2.jpg</Key>
</Object>
</Delete>

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 144
Connection: close
Date: Tue, 20 Aug 2019 11:59:35 GMT
Server: tencent-cos
x-cos-request-id: NWQ1YmUwYTdfM2FiMDJhMDlfYzczN18zMGM1****

<DeleteResult>
<Deleted>
<Key>example-object-1.jpg</Key>
</Deleted>
<Deleted>
<Key>example-object-2.jpg</Key>
</Deleted>
</DeleteResult>

Sample 2: simple use case (using the Quiet mode)

Request

POST /?delete HTTP/1.1
Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.com
Date: Tue, 20 Aug 2019 12:12:26 GMT
Content-Type: application/xml
Content-Length: 157
Content-MD5: +iI9kJvM2k/y5y3nHcn8BQ==
Authorization: q-sign-algorithm=sha1&q-ak=************************************&q-sign-time=1566303146;1566310346&q-key-time=1566303146;1566310346&q-header-list=content-length;content-md5;content-type;date;host&q-url-param-list=delete&q-signature=****************************************
Connection: close

<Delete>
<Quiet>true</Quiet>
<Object>
<Key>example-object-1.jpg</Key>
</Object>
<Object>
<Key>example-object-2.jpg</Key>
</Object>
</Delete>

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 15
Connection: close
Date: Tue, 20 Aug 2019 12:12:27 GMT
Server: tencent-cos
x-cos-request-id: NWQ1YmUzYWFfMTljMDJhMDlfNTg3ZV8zNDI0****

<DeleteResult/>

Sample 3: versioning-enabled (creating a delete marker)

Request

POST /?delete HTTP/1.1
Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.com
Date: Wed, 21 Aug 2019 12:04:03 GMT
Content-Type: application/xml
Content-Length: 100
Content-MD5: MowFtlG7iwK7Wmk79IVXFA==
Authorization: q-sign-algorithm=sha1&q-ak=************************************&q-sign-time=1566389043;1566396243&q-key-time=1566389043;1566396243&q-header-list=content-length;content-md5;content-type;date;host&q-url-param-list=delete&q-signature=****************************************
Connection: close

<Delete>
<Quiet>false</Quiet>
<Object>
<Key>example-object-1.jpg</Key>
</Object>
</Delete>

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 200
Connection: close
Date: Wed, 21 Aug 2019 12:04:03 GMT
Server: tencent-cos
x-cos-request-id: NWQ1ZDMzMzNfNDhiNDBiMDlfMmIzNzZfMTBh****

<DeleteResult>
<Deleted>
<Key>example-object-1.jpg</Key>
<DeleteMarker>true</DeleteMarker>
<DeleteMarkerVersionId>MTg0NDUxNzc2ODQ2NjU3ODM4NTc</DeleteMarkerVersionId>
</Deleted>
</DeleteResult>

Sample 4: deleting an object of a specified version

Request

POST /?delete HTTP/1.1
Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.com
Date: Wed, 21 Aug 2019 11:24:43 GMT
Content-Type: application/xml
Content-Length: 154
Content-MD5: EwFydeQSMzaHWi0qMTOGWw==
Authorization: q-sign-algorithm=sha1&q-ak=************************************&q-sign-time=1566386683;1566393883&q-key-time=1566386683;1566393883&q-header-list=content-length;content-md5;content-type;date;host&q-url-param-list=delete&q-signature=****************************************
Connection: close

<Delete>
<Quiet>false</Quiet>
<Object>
<Key>example-object-2.jpg</Key>
<VersionId>MTg0NDUxNzc2ODcwMjYyNjIwMTM</VersionId>
</Object>
</Delete>

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 140
Connection: close
Date: Wed, 21 Aug 2019 11:24:44 GMT
Server: tencent-cos
x-cos-request-id: NWQ1ZDI5ZmJfNDhiNDBiMDlfMmIzODNfMTA0****

<DeleteResult>
<Deleted>
<Key>example-object-2.jpg</Key>
<VersionId>MTg0NDUxNzc2ODcwMjYyNjIwMTM</VersionId>
</Deleted>
</DeleteResult>

Sample 5: deleting a delete marker

Request

POST /?delete HTTP/1.1
Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.com
Date: Wed, 21 Aug 2019 12:04:04 GMT
Content-Type: application/xml
Content-Length: 154
Content-MD5: EKphCPpHcKiVqJtMqE+DmA==
Authorization: q-sign-algorithm=sha1&q-ak=************************************&q-sign-time=1566389044;1566396244&q-key-time=1566389044;1566396244&q-header-list=content-length;content-md5;content-type;date;host&q-url-param-list=delete&q-signature=****************************************
Connection: close

<Delete>
<Quiet>false</Quiet>
<Object>
<Key>example-object-1.jpg</Key>
<VersionId>MTg0NDUxNzc2ODQ2NjU3ODM4NTc</VersionId>
</Object>
</Delete>

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 253
Connection: close
Date: Wed, 21 Aug 2019 12:04:04 GMT
Server: tencent-cos
x-cos-request-id: NWQ1ZDMzMzRfYmIwMmEwOV83YTQzXzEyM2Ri****

<DeleteResult>
<Deleted>
<Key>example-object-1.jpg</Key>
<DeleteMarker>true</DeleteMarker>
<DeleteMarkerVersionId>MTg0NDUxNzc2ODQ2NjU3ODM4NTc</DeleteMarkerVersionId>
<VersionId>MTg0NDUxNzc2ODQ2NjU3ODM4NTc</VersionId>
</Deleted>
</DeleteResult>

Sample 6: failed to delete some objects

Request

POST /?delete HTTP/1.1
Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.com
Date: Wed, 21 Aug 2019 12:04:05 GMT
Content-Type: application/xml
Content-Length: 436
Content-MD5: ZAbgvje31aO+0j7pkEkYvQ==
Authorization: q-sign-algorithm=sha1&q-ak=************************************&q-sign-time=1566389045;1566396245&q-key-time=1566389045;1566396245&q-header-list=content-length;content-md5;content-type;date;host&q-url-param-list=delete&q-signature=****************************************
Connection: close

<Delete>
<Quiet>false</Quiet>
<Object>
<Key>example-object-1.jpg</Key>
</Object>
<Object>
<Key>example-object-2.jpg</Key>
<VersionId>MTg0NDUxNzc2ODQ2NjQ1MjM5MTk</VersionId>
</Object>
<Object>
<Key>example-object-3.jpg</Key>
<VersionId>MTg0NDUxNzc2ODQ2NjQwMTIwMDI</VersionId>
</Object>
<Object>
<Key>example-object-4.jpg</Key>
<VersionId>MTg0NDUxNzc2ODQ2NjQ0NjI0MDQ</VersionId>
</Object>
</Delete>

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 703
Connection: close
Date: Wed, 21 Aug 2019 12:04:06 GMT
Server: tencent-cos
x-cos-request-id: NWQ1ZDMzMzVfOTNjMjJhMDlfMzhiM18xMWY3****

<DeleteResult>
<Deleted>
<Key>example-object-1.jpg</Key>
<DeleteMarker>true</DeleteMarker>
<DeleteMarkerVersionId>MTg0NDUxNzc2ODQ2NjM1NTI2NDY</DeleteMarkerVersionId>
</Deleted>
<Deleted>
<Key>example-object-2.jpg</Key>
<VersionId>MTg0NDUxNzc2ODQ2NjQ1MjM5MTk</VersionId>
</Deleted>
<Deleted>
<Key>example-object-3.jpg</Key>
<DeleteMarker>true</DeleteMarker>
<DeleteMarkerVersionId>MTg0NDUxNzc2ODQ2NjQwMTIwMDI</DeleteMarkerVersionId>
<VersionId>MTg0NDUxNzc2ODQ2NjQwMTIwMDI</VersionId>
</Deleted>
<Error>
<Key>example-object-4.jpg</Key>
<VersionId>MTg0NDUxNzc2ODQ2NjQ0NjI0MDQ</VersionId>
<Code>PathConflict</Code>
<Message>Path conflict.</Message>
</Error>
</DeleteResult>


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan