Available in Classic and VPC
Delete a container (bucket) or object within a container.
Deleted containers and objects cannot be recovered. Using the --all option will delete all containers and objects in your account, so verify the target before executing this command.
Syntax
The delete syntax is as follows:
-
Account (deletes all containers and objects)
swift delete \ --all \ [--leave-segments] \ [--object-threads <threads>] \ [--container-threads <threads>] \ [--header <header:value>] -
Container (deletes container and all objects inside)
swift delete \ <container> \ [--prefix <prefix>] \ [--leave-segments] \ [--object-threads <threads>] \ [--container-threads <threads>] \ [--header <header:value>] -
Object (deletes single or multiple objects)
swift delete \ <container> <object> [<object> ...] \ [--leave-segments] \ [--object-threads <threads>] \ [--header <header:value>]
Options
This section describes the options available when running delete.
Required options
The following options are required for delete.
| Options | Type | Required | Description |
|---|---|---|---|
<container> |
String | Conditional | Container name to delete
|
--all |
Boolean | Conditional | Deletes all containers and objects in the account.
|
Optional options
These are the optional options for delete. Options that are not specified will use their default values.
| Options | Type | Required | Description |
|---|---|---|---|
<object> |
List | Optional | Object names to delete
|
--prefix |
String | Optional | Deletes only objects that begin with the specified prefix. |
--leave-segments |
Boolean | Optional | Does not delete segments of manifest objects. |
--object-threads |
Integer | Optional | Number of threads to use for deleting objects
|
--container-threads |
Integer | Optional | Number of threads to use for deleting containers
|
--header |
String | Optional | Custom header to use in the deletion request
|
Common options
For information about the options common to all swift subcommands, see Archive Storage options.
Examples
When you run the command, the names of the deleted objects are displayed; if you deleted a container, its name is also displayed.
Command
The following is an example command for deleting an object.
swift delete test-container-01 copied.txt
The following is an example command for deleting an object using a prefix.
swift delete test-container-01 --prefix docs/
The following is an example command for deleting a container after deleting all objects within it.
swift delete test-container-01
Output
The following is an example output for deleting an object.
copied.txt
The following is an example output for deleting an object using a prefix.
docs/report.txt
The following is an example output of deleting a container after deleting all objects within it.
docs/report.txt
sample.txt
test-container-01