This page shows you how to list the objects stored in your Cloud Storage buckets, which are ordered in the list lexicographically by name. For an overview of buckets and objects, read the Key Terms.
To list the objects in a bucket:
Console
- Open the Cloud Storage browser in the Google Cloud Console.
Open the Cloud Storage browser In the bucket list, click on the name of the bucket whose contents you want to view.
Optionally, use filtering to narrow the results in your list.
gsutil
Use the gsutil ls
command with the -r
flag:
gsutil ls -r gs://BUCKET_NAME/**
Where:
BUCKET_NAME
is the name of the bucket whose objects you want to list. For example,my-bucket
.
The response looks like the following example:
gs://my-bucket/cats.jpeg gs://my-bucket/dogs.jpeg gs://my-bucket/thesis.txt ...
Code samples
For more information, see the
Cloud Storage C++ API reference documentation.
The following sample lists all objects in a bucket: The following sample lists objects with a given prefix:
For more information, see the
Cloud Storage C# API reference documentation.
The following sample lists all objects in a bucket: The following sample lists objects with a given prefix:
For more information, see the
Cloud Storage Go API reference documentation.
The following sample lists all objects in a bucket: The following sample lists objects with a given prefix:
For more information, see the
Cloud Storage Java API reference documentation.
The following sample lists all objects in a bucket: The following sample lists objects with a given prefix:
For more information, see the
Cloud Storage Node.js API reference documentation.
The following sample lists all objects in a bucket: The following sample lists objects with a given prefix:
For more information, see the
Cloud Storage PHP API reference documentation.
The following sample lists all objects in a bucket: The following sample lists objects with a given prefix:
For more information, see the
Cloud Storage Python API reference documentation.
The following sample lists all objects in a bucket: The following sample lists objects with a given prefix:
For more information, see the
Cloud Storage Ruby API reference documentation.
The following sample lists all objects in a bucket: The following sample lists objects with a given prefix: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 aGET
Bucket request:curl -X GET -H "Authorization: Bearer OAUTH2_TOKEN" \ "https://storage.googleapis.com/storage/v1/b/BUCKET_NAME/o"
Where:
OAUTH2_TOKEN
is the access token you generated in Step 1.BUCKET_NAME
is the name of the bucket whose objects you want to list. For example,my-bucket
.
You can use a
prefix=PREFIX
query string parameter to limit results to objects that have the specified prefix.
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 aGET
Bucket request:curl -X GET -H "Authorization: Bearer OAUTH2_TOKEN" \ "https://storage.googleapis.com/BUCKET_NAME"
Where:
OAUTH2_TOKEN
is the access token you generated in Step 1.BUCKET_NAME
is the name of the bucket whose objects you want to list. For example,my-bucket
.
You can use a
prefix=PREFIX
query string parameter to limit results to buckets that have the specified prefix.
What's next
- Download an object from your bucket.
- View and edit object metadata.
- Delete objects from your bucket.