The delete-multiple-objects command is used to delete multiple objects from the same bucket.
Usage notes
By default, an Alibaba Cloud account has the permissions to delete the tags configured for an object. Deleting tags as a RAM user or by using Security Token Service (STS) requires
oss:DeleteObject
permission. For more information, see Attach a custom policy to a RAM user.You can delete up to 1,000 objects at a time by calling the DeleteMultipleObjects operation.
Deleted objects cannot be recovered. Please 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 | Configuration properties for the deletion. |
--encoding-type | string | Encoding type of the object names in the response. |
The delete-multiple-objects command corresponds to the DeleteMultipleObjects operation. For more information about the parameters in the DeleteMultipleObjects operation, see DeleteMultipleObjects.
--delete
The --delete configuration option supports both XML and JSON formats. If the value of the option contains the 'file://' prefix, configuration parameters are read from the specified 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" } ] }
For more information about supported global command-line options, see Command-line options.
Examples
Delete multiple objects in
examplebucket
.Create a configuration file named delete.xml and add the following code:
<?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 configuration file named delete.json and add the following code:
{ "Quiet": "false", "Object": [ { "Key": "multipart.data" }, { "Key": "test.jpg" } ] }
Sample command:
ossutil api delete-multiple-objects --bucket examplebucket --delete file://delete.json
Configure parameters in the following command in the JSON format:
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 configuration file named delete.xml and add the following code:
<?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 configuration file named delete.json and add the following code:
{ "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
Configure parameters in the following command in the JSON format:
ossutil api delete-multiple-objects --bucket examplebucket --delete "{\"Quiet\":\"false\",\"Object\":[{\"Key\":\"multipart.data\",\"VersionId\":\"CAEQNRiBgIDyz.6C0BYiIGQ2NWEwNmVhNTA3ZTQ3MzM5ODliYjM1ZTdjYjA4****\"},{\"Key\":\"test.jpg\",\"VersionId\":\"CAEQMhiBgIDB3aWB0BYiIGUzYTA3YzliMzVmNzRkZGM5NjllYTVlMjYyYWEy****\"}]}"