Deletes multiple objects from the same bucket.
Usage notes
-
Alibaba Cloud accounts can delete object tags by default. RAM users and STS require
oss:DeleteObjectpermission. For more information, see Grant a custom policy. -
A single call deletes up to 1,000 objects.
-
Deleted objects cannot be recovered. Proceed with caution.
Command syntax
ossutil api delete-multiple-objects --bucket value --delete value [flags]
|
Parameter |
Type |
Description |
|
--bucket |
string |
Name of the bucket. |
|
--delete |
string |
Deletion configuration in XML or JSON format. |
|
--encoding-type |
string |
Encoding type for object names in the response. |
This command maps to the DeleteMultipleObjects API. For parameter details, see DeleteMultipleObjects.
--delete
The --delete option accepts XML and JSON formats. Use the 'file://' prefix to load configuration from a file.
-
XML format:
<Delete> <Quiet>false</Quiet> <Object> <Key>string</Key> <VersionId>string</VersionId> </Object> <Object> <Key>string</Key> <VersionId>string</VersionId> </Object> </Delete> -
JSON format:
{ "Quiet": "false", "Object": [ { "Key": "string", "VersionId": "string" }, { "Key": "string", "VersionId": "string" } ] }
All supported global options are documented in Command-line options.
Examples
-
Delete multiple objects in
examplebucket.-
Create a file named delete.xml:
<?xml version="1.0" encoding="UTF-8"?> <Delete> <Quiet>false</Quiet> <Object> <Key>multipart.data</Key> </Object> <Object> <Key>test.jpg</Key> </Object> </Delete>Sample command:
ossutil api delete-multiple-objects --bucket examplebucket --delete file://delete.xml -
Create a file named delete.json:
{ "Quiet": "false", "Object": [ { "Key": "multipart.data" }, { "Key": "test.jpg" } ] }Sample command:
ossutil api delete-multiple-objects --bucket examplebucket --delete file://delete.json -
Pass parameters inline as JSON:
ossutil api delete-multiple-objects --bucket examplebucket --delete "{\"Quiet\":\"false\",\"Object\":[{\"Key\":\"multipart.data\"},{\"Key\":\"test.jpg\"}]}"
-
-
Delete multiple specified versions of objects in
examplebucket.-
Create a file named delete.xml:
<?xml version="1.0" encoding="UTF-8"?> <Delete> <Quiet>false</Quiet> <Object> <Key>multipart.data</Key> </Object> <Object> <Key>test.jpg</Key> </Object> </Delete>Sample command:
ossutil api delete-multiple-objects --bucket examplebucket --delete file://delete.xml -
Create a file named delete.json:
{ "Quiet": "false", "Object": [ { "Key": "multipart.data", "VersionId": "CAEQNRiBgIDyz.6C0BYiIGQ2NWEwNmVhNTA3ZTQ3MzM5ODliYjM1ZTdjYjA4****" }, { "Key": "test.jpg", "VersionId": "CAEQMhiBgIDB3aWB0BYiIGUzYTA3YzliMzVmNzRkZGM5NjllYTVlMjYyYWEy****" } ] }Sample command:
ossutil api delete-multiple-objects --bucket examplebucket --delete file://delete.json -
Pass parameters inline as JSON:
ossutil api delete-multiple-objects --bucket examplebucket --delete "{\"Quiet\":\"false\",\"Object\":[{\"Key\":\"multipart.data\",\"VersionId\":\"CAEQNRiBgIDyz.6C0BYiIGQ2NWEwNmVhNTA3ZTQ3MzM5ODliYjM1ZTdjYjA4****\"},{\"Key\":\"test.jpg\",\"VersionId\":\"CAEQMhiBgIDB3aWB0BYiIGUzYTA3YzliMzVmNzRkZGM5NjllYTVlMjYyYWEy****\"}]}"
-