New API Documentation - Developer Preview Available
We are excited to announce the developer preview of our new API documentation for AWS SDK for JavaScript v3. Please follow instructions on the landing page to leave us your feedback.
This action enables you to delete multiple objects from a bucket using a single HTTP
request. If you know the object keys that you want to delete, then this action provides a
suitable alternative to sending individual delete requests, reducing per-request
overhead.
The request contains a list of up to 1000 keys that you want to delete. In the XML, you
provide the object key names, and optionally, version IDs if you want to delete a specific
version of the object from a versioning-enabled bucket. For each key, Amazon S3 performs a
delete action and returns the result of that delete, success, or failure, in the response.
Note that if the object specified in the request is not found, Amazon S3 returns the result as
deleted.
The action supports two modes for the response: verbose and quiet. By default, the
action uses verbose mode in which the response includes the result of deletion of each key
in your request. In quiet mode the response includes only keys where the delete action
encountered an error. For a successful deletion, the action does not return any information
about the delete in the response body.
When performing this action on an MFA Delete enabled bucket, that attempts to delete any
versioned objects, you must include an MFA token. If you do not provide one, the entire
request will fail, even if there are non-versioned objects you are trying to delete. If you
provide an invalid token, whether there are versioned keys in the request or not, the
entire Multi-Object Delete request will fail. For information about MFA Delete, see MFA
Delete.
Finally, the Content-MD5 header is required for all Multi-Object Delete requests. Amazon S3 uses the header value to ensure that your request body has not been altered in
transit.
The following operations are related to DeleteObjects:
Base exception class for all service exceptions from S3 service.
Example
To delete multiple object versions from a versioned bucket
// The following example deletes objects from a bucket. The request specifies object versions. S3 deletes specific object versions and returns the key and versions of deleted objects in the response. constinput = { "Bucket":"examplebucket", "Delete": { "Objects": [ { "Key":"HappyFace.jpg", "VersionId":"2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b" }, { "Key":"HappyFace.jpg", "VersionId":"yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd" } ], "Quiet":false } }; constcommand = newDeleteObjectsCommand(input); constresponse = awaitclient.send(command); /* response == { "Deleted": [ { "Key": "HappyFace.jpg", "VersionId": "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd" }, { "Key": "HappyFace.jpg", "VersionId": "2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b" } ] } */ // example id: to-delete-multiple-object-versions-from-a-versioned-bucket-1483147087737
Example
To delete multiple objects from a versioned bucket
// The following example deletes objects from a bucket. The bucket is versioned, and the request does not specify the object version to delete. In this case, all versions remain in the bucket and S3 adds a delete marker. constinput = { "Bucket":"examplebucket", "Delete": { "Objects": [ { "Key":"objectkey1" }, { "Key":"objectkey2" } ], "Quiet":false } }; constcommand = newDeleteObjectsCommand(input); constresponse = awaitclient.send(command); /* response == { "Deleted": [ { "DeleteMarker": "true", "DeleteMarkerVersionId": "A._w1z6EFiCF5uhtQMDal9JDkID9tQ7F", "Key": "objectkey1" }, { "DeleteMarker": "true", "DeleteMarkerVersionId": "iOd_ORxhkKe_e8G8_oSGxt2PjsCZKlkt", "Key": "objectkey2" } ] } */ // example id: to-delete-multiple-objects-from-a-versioned-bucket-1483146248805
This action enables you to delete multiple objects from a bucket using a single HTTP request. If you know the object keys that you want to delete, then this action provides a suitable alternative to sending individual delete requests, reducing per-request overhead.
The request contains a list of up to 1000 keys that you want to delete. In the XML, you provide the object key names, and optionally, version IDs if you want to delete a specific version of the object from a versioning-enabled bucket. For each key, Amazon S3 performs a delete action and returns the result of that delete, success, or failure, in the response. Note that if the object specified in the request is not found, Amazon S3 returns the result as deleted.
The action supports two modes for the response: verbose and quiet. By default, the action uses verbose mode in which the response includes the result of deletion of each key in your request. In quiet mode the response includes only keys where the delete action encountered an error. For a successful deletion, the action does not return any information about the delete in the response body.
When performing this action on an MFA Delete enabled bucket, that attempts to delete any versioned objects, you must include an MFA token. If you do not provide one, the entire request will fail, even if there are non-versioned objects you are trying to delete. If you provide an invalid token, whether there are versioned keys in the request or not, the entire Multi-Object Delete request will fail. For information about MFA Delete, see MFA Delete.
Finally, the Content-MD5 header is required for all Multi-Object Delete requests. Amazon S3 uses the header value to ensure that your request body has not been altered in transit.
The following operations are related to
DeleteObjects
:CreateMultipartUpload
UploadPart
CompleteMultipartUpload
ListParts
AbortMultipartUpload
Example
Use a bare-bones client and the command you need to make an API call.
Param
DeleteObjectsCommandInput
Returns
DeleteObjectsCommandOutput
See
input
shape.response
shape.config
shape.Throws
S3ServiceException
Base exception class for all service exceptions from S3 service.
Example
To delete multiple object versions from a versioned bucket
Example
To delete multiple objects from a versioned bucket