Deleting objects from a directory bucket
You can delete objects from an Amazon S3 directory bucket by using the Amazon S3 console, AWS Command Line Interface (AWS CLI), or AWS SDKs. For more information, see Working with directory buckets and S3 Express One Zone.
Warning
-
Deleting an object can't be undone.
-
This action deletes all specified objects. When deleting folders, wait for the delete action to finish before adding new objects to the folder. Otherwise, new objects might be deleted as well.
Note
When you programmatically delete multiple objects from a directory bucket, note the following:
-
Object keys in
DeleteObjects
requests must contain at least one non-white space character. Strings of all white space characters are not supported. -
Object keys in
DeleteObjects
requests cannot contain Unicode control characters, except for newline (\n
), tab (\t
), and carriage return (\r
).
To delete objects
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/
. -
In the left navigation pane, choose Buckets.
-
Choose the Directory buckets tab.
-
Choose the directory bucket that contains the objects that you want to delete.
-
Choose the Objects tab. In the Objects list, select the check box to the left of the object or objects that you want to delete.
-
Choose Delete.
-
On the Delete objects page, enter
permanently delete
in the text box. -
Choose Delete objects.
The following delete-object
example command shows how you can use the AWS CLI
to delete an object from a directory bucket. To run this command, replace the
with your own information.user input placeholders
aws s3api delete-object --bucket
bucket-base-name
--zone-id
--x-s3 --keyKEY_NAME
For more information, see delete-object
The following delete-objects
example command shows how you can use the AWS CLI
to delete objects from a directory bucket. To run this command, replace the
with your own information.user input placeholders
The delete.json
file is as follows:
{ "Objects": [ { "Key": "0.txt" }, { "Key": "1.txt" }, { "Key": "2.txt" }, { "Key": "3.txt" } ] }
The delete-objects
example command is as follows:
aws s3api delete-objects --bucket
bucket-base-name
--zone-id
--x-s3 --delete file://delete.json
For more information, see delete-objects