A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/storage/docs/listing-objects below:

List objects | Cloud Storage

Skip to main content List objects

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 begin

To 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 permissions

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 Console
  1. In the Google Cloud console, go to the Cloud Storage Buckets page.

    Go to Buckets

  2. In the bucket list, click the name of the bucket whose contents you want to view.

Command line

Use the gcloud storage ls command:

gcloud storage ls gs://BUCKET_NAME

Where:

Client libraries 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:

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:

Go

For 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:

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.

The following sample lists all objects in a bucket:

The following sample lists objects with a given prefix:

Node.js

For 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:

PHP

For 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:

Python

For 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:

Ruby

For 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 Console
  1. In the Google Cloud console, go to the Cloud Storage Buckets page.

    Go to Buckets

  2. In the bucket list, click the name of the bucket that contains the folder.

  3. In the Objects tab of the Bucket details page, click the name of the folder whose contents you want to view.

Command line

Use the gcloud storage ls command to list the objects in a folder:

gcloud storage ls gs://BUCKET_NAME/FOLDER_NAME

Where:

REST APIs JSON API

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 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 case

Using 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/.

Note: When filtering by managed folders, set the 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.

Console

See filtering and sorting for information on how to filter and sort objects in buckets or folders.

Command line

You 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 contexts

You can use a filter to show only objects that have the specified contexts (preview) in the list response.

Command line

Use the gcloud alpha storage objects list command:

gcloud alpha storage objects list gs://BUCKET_NAME --metadata-filter='contexts."KEY"="VALUE"'

Where:

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 API

The 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:

Syntax

Cloud Storage supports the following syntax for the filter.

Syntax Description contexts."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":*

Match any object that does not have a context with the specified key attached.

NOT contexts."KEY"="VALUE"

OR

-contexts."KEY"="VALUE"

Match any object that does not have a context with the specified key and value attached. Performance considerations when listing objects

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 next

Except 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