Discover
Get started
Create buckets
Access and manage buckets
Upload and download objects
Access and manage objects
Get insights on your stored data
Cache objects
Control data lifecycles
Make requests
Secure data
Monitor data and usage
Protection, backup, and recovery
Mount buckets with Cloud Storage FUSE
Work across products, Clouds, and platforms
Troubleshoot
Stay organized with collections Save and categorize content based on your preferences.
This page shows you how to list the objects stored in your Cloud Storage buckets, which are ordered in the list lexicographically by name.
Before you beginTo get the permissions that you need to list objects, ask your administrator to grant you the Storage Object Viewer (roles/storage.objectViewer
) IAM role for the bucket that contains the objects you want to list. If you want to list objects within managed folders, you can grant roles/storage.objectViewer
on the managed folder that contains the objects you want to view instead of the bucket.
If you plan on using the Google Cloud console to perform the tasks on this page, ask your administrator to grant you the Viewer (roles/viewer
) basic role in addition to the Storage Object Viewer (roles/storage.objectViewer
) role.
These roles contain the permissions required to list objects. To see the exact permissions that are required, expand the Required permissions section:
Required permissionsstorage.objects.list
storage.buckets.list
You can also get these permissions with other predefined roles or custom roles.
For information about granting roles for buckets, see Set and manage IAM policies on buckets.
List the objects in a bucket ConsoleIn the bucket list, click the name of the bucket whose contents you want to view.
Use the gcloud storage ls
command:
gcloud storage ls gs://BUCKET_NAME
Where:
BUCKET_NAME
is the name of the bucket that contains the objects you want to list. For example, my-bucket
.For more information, see the Cloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample lists all objects in a bucket:
The following sample lists objects with a given prefix:
C#For more information, see the Cloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample lists all objects in a bucket:
The following sample lists objects with a given prefix:
GoFor more information, see the Cloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample lists all objects in a bucket:
The following sample lists objects with a given prefix:
JavaFor more information, see the Cloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample lists all objects in a bucket:
The following sample lists objects with a given prefix:
Node.jsFor more information, see the Cloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample lists all objects in a bucket:
The following sample lists objects with a given prefix:
PHPFor more information, see the Cloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample lists all objects in a bucket:
The following sample lists objects with a given prefix:
PythonFor more information, see the Cloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample lists all objects in a bucket:
The following sample lists objects with a given prefix:
RubyFor more information, see the Cloud Storage Ruby API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample lists all objects in a bucket:
The following sample lists objects with a given prefix:
REST APIs List the objects in a folder ConsoleIn the bucket list, click the name of the bucket that contains the folder.
In the Objects tab of the Bucket details page, click the name of the folder whose contents you want to view.
Use the gcloud storage ls
command to list the objects in a folder:
gcloud storage ls gs://BUCKET_NAME/FOLDER_NAME
Where:
BUCKET_NAME
is the name of the bucket that contains the folder. For example, my-bucket
.
FOLDER_NAME
is the name of the folder that contains the objects you want to list. For example, my-folder
.
To list the objects in a folder, use a list objects request with the prefix
and delimiter
parameters. When the prefix
parameter is set, the list operation is scoped to only return objects and folders under the prefix. When the delimiter
parameter is set, the prefixes[]
list in the response populates with the names of folders under the specified prefix.
For example:
To list all objects in the folder image/
within the bucket my-bucket
, use the following URL: "https://storage.googleapis.com/storage/v1/b/my-bucket/o?prefix=image&delimiter=/"
.
This could return the objects my-bucket/image/cat.jpeg
and my-bucket/image/dog.jpeg
.
To include objects in subfolders within image/
, remove the delimiter
parameter: "https://storage.googleapis.com/storage/v1/b/my-bucket/o?prefix=image"
.
This could return the objects my-bucket/image/cat.jpeg
, my-bucket/image/dog.jpeg
, and my-bucket/image/dog/shiba.jpeg
.
To use wildcards in your list objects request and match objects by glob expression, use the matchGlob
parameter. For example, matchGlob=**.jpeg
matches all objects that end in .jpeg
. When you use matchGlob
, you must set delimiter
to /
.
For example, use the following URL to match all objects within the folder image
that end in .jpeg
: "https://storage.googleapis.com/storage/v1/b/my-bucket/o?prefix=image&delimiter=/&matchGlob=**.jpeg"
For more details about using parameters to filter for objects, see the Objects list JSON API reference documentation.
Use caseUsing prefix
to list the contents of a folder can be useful for when you only have the permission to list objects in the folder, but not the whole bucket. For example, say you have the Storage Object Viewer (roles/storage.objectViewer
) IAM role for the managed folder my-bucket/my-managed-folder-a/
, but not for the managed folder my-bucket/my-managed-folder-b/
. To return only the objects in my-managed-folder-a
, you can specify prefix=my-managed-folder-a/
.
includeFoldersAsPrefixes
parameter to true
and the delimiter
parameter to /
. Filtering objects
When listing objects, you can use prefixes or suffixes in your list request to filter objects by name.
ConsoleSee filtering and sorting for information on how to filter and sort objects in buckets or folders.
Command lineYou can use wildcards in your gcloud storage ls
command to filter objects by prefix or suffix. For example, the following command only lists objects in the bucket my-bucket
whose name begins with image
and ends with .png
:
gcloud storage ls gs://my-bucket/image*.png
If the request is successful, the response looks similar to the following:
gs://my-bucket/image.png gs://my-bucket/image-dog.png gs://my-bucket/image-cat.png ...
You can use double-star wildcards to match zero or more folder levels in a path. For example, the following command only lists objects whose name ends in .jpeg
in any folder or subfolder within the bucket my-bucket
:
gcloud storage ls gs://my-bucket/**/*.jpeg
If the request is successful, the response looks similar to the following:
gs://my-bucket/puppy.jpeg gs://my-bucket/pug.jpeg gs://my-bucket/pets/dog.jpeg ...REST APIs
See list objects in folders for information on how to filter objects by folder or object name prefix.
Filter objects by contextsYou can use a filter to show only objects that have the specified contexts (preview) in the list response.
Command lineUse the gcloud alpha storage objects list
command:
gcloud alpha storage objects list gs://BUCKET_NAME --metadata-filter='contexts."KEY"="VALUE"'
Where:
BUCKET_NAME
is the name of the bucket containing the object whose context you want to filter by. For example, my-bucket
.KEY
is the context key attached to the object.VALUE
is the value associated with the context key.If successful, the response looks similar to the following example:
--- bucket: my-bucket contexts: Department: createTime: '2023-01-01T00:00:00.000000+00:00' type: CUSTOM updateTime: '2023-01-01T00:00:00.000000+00:00' value: HR DataClassification: createTime: '2023-01-01T00:00:00.000000+00:00' type: CUSTOM updateTime: '2023-01-01T00:00:00.000000+00:00' value: Confidential name: employees.txt ...Note: To limit the output to only the context keys and values, use
--format=contextsonly
. Client libraries Java
For more information, see the Cloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
REST APIs JSON APIThe Object: list
request shows an example of how to use the filter
query parameter:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://storage.googleapis.com/storage/v1/b/BUCKET_NAME/o/?filter=contexts.%22KEY%22%3D%22VALUE%22"
Where:
BUCKET_NAME
is the name of the bucket containing the object whose context you want to filter by. For example, my-bucket
.KEY
is the context key attached to the object.VALUE
is the value associated with the context key.Cloud Storage supports the following syntax for the filter.
Syntax Descriptioncontexts."KEY":*
Match any object that has a context with the specified key attached. contexts."KEY"="VALUE"
Match any object that has a context with the specified key and value attached.
NOT contexts."KEY":*
OR
-contexts."KEY":*
NOT contexts."KEY"="VALUE"
OR
-contexts."KEY"="VALUE"
The underlying structure of buckets with hierarchical namespace enabled influences the performance of the listing objects operation, when compared to flat namespace buckets. For more information, see Optimize performance in buckets with hierarchical namespace enabled.
What's nextExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-13 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-13 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.5