This page shows you how to delete objects from your buckets in Cloud Storage. For an overview of objects, read the Key Terms.
To delete an object from one of your Cloud Storage buckets:
Console
- Open the Cloud Storage browser in the Google Cloud Console.
Open the Cloud Storage browser In the list of buckets, click on the name of the bucket that contains the object you want to delete.
In the Objects tab, navigate to the object.
Click the checkbox next to the object you want to delete.
Click the Delete button.
Click Delete in the dialog that appears.
gsutil
Use the gsutil rm
command:
gsutil rm gs://[BUCKET_NAME]/[OBJECT_NAME]
Where:
[BUCKET_NAME]
is the name of the bucket containing the object you want to delete. For example,my-bucket
.[OBJECT_NAME]
is the name of the object you want to delete. For example,pets/dog.png
.
If successful, the response looks like the following example:
Operation completed over 1 objects.
Code samples
For more information, see the
Cloud Storage C++ API reference documentation
.
For more information, see the
Cloud Storage C# API reference documentation
.
For more information, see the
Cloud Storage Go API reference documentation
.
For more information, see the
Cloud Storage Java API reference documentation
.
For more information, see the
Cloud Storage Node.js API reference documentation
.
For more information, see the
Cloud Storage PHP API reference documentation
.
For more information, see the
Cloud Storage Python API reference documentation
.
For more information, see the
Cloud Storage Ruby API reference documentation
.
C++
C#
Go
Java
Node.js
PHP
Python
Ruby
REST APIs
JSON API
- Get an authorization access token from the OAuth 2.0 Playground. Configure the playground to use your own OAuth credentials.
Use
cURL
to call the JSON API with aDELETE
request:curl -X DELETE \ -H "Authorization: Bearer [OAUTH2_TOKEN]" \ "https://storage.googleapis.com/storage/v1/b/[BUCKET_NAME]/o/[OBJECT_NAME]"
Where:
[OAUTH2_TOKEN]
is the name of the access token you generated in Step 1.[BUCKET_NAME]
is the name of the bucket containing the object you want to delete. For example,my-bucket
.[OBJECT_NAME]
is the name of the object you want to delete. For example,pets/dog.png
.
XML API
- Get an authorization access token from the OAuth 2.0 Playground. Configure the playground to use your own OAuth credentials.
Use
cURL
to call the XML API with aDELETE Object
request:curl -X DELETE \ -H "Authorization: Bearer [OAUTH2_TOKEN]" \ "https://storage.googleapis.com/[BUCKET_NAME]/[OBJECT_NAME]"
Where:
[OAUTH2_TOKEN]
is the name of the access token you generated in Step 1.[BUCKET_NAME]
is the name of the bucket containing the object you want to delete. For example,my-bucket
.[OBJECT_NAME]
is the name of the object you want to delete. For example,pets/dog.png
.