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
- In the Google Cloud Console, go to the Cloud Storage Browser page.
In the list of buckets, click on the name of the bucket that contains the object you want to delete.
The Bucket details page opens, with the Objects tab selected.
Navigate to the object, which may be located in a folder.
Click the checkbox next to the object you want to delete.
Click the Delete button.
Click Delete in the dialog that appears.
To learn how to get detailed error information about failed operations in the Cloud Storage browser, see Troubleshooting.
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
.