Retrieves a list of objects matching the criteria. Try it now or see an example .
In conjunction with the
prefix
filter, the use of the
delimiter
parameter allows the
list
method to operate like a directory listing, despite the object namespace being flat. For example, if
delimiter
were set to "/", then listing objects from a bucket whose objects were "a/b", "a/c", "d", "e", "e/f" would return objects "d" and "e", and prefixes "a/" and "e/".
The authenticated user must have
READER
permissions on the
bucket
.
Request
HTTP request
GET https://www.googleapis.com/storage/v1beta1/b/bucket/o
Parameters
Parameter name | Value | Description |
---|---|---|
Required parameters | ||
bucket
|
string
|
Name of the bucket in which to look for objects. |
Optional parameters | ||
delimiter
|
string
|
Returns results in a directory-like mode.
items
will contain only objects whose names, aside from the
prefix
, do not contain
delimiter
. Objects whose names, aside from the
prefix
, contain
delimiter
will have their name, truncated after the
delimiter
, returned in
prefixes
. Duplicate
prefixes
are omitted.
|
max-results
|
unsigned integer
|
Maximum number of
items
plus
prefixes
to return. As duplicate
prefixes
are omitted, fewer total results may be returned than requested.
|
pageToken
|
string
|
A previously-returned page token representing part of the larger set of results to view. |
prefix
|
string
|
Filter results to objects whose names begin with this prefix. |
projection
|
string
|
Set of properties to return. Defaults to
no_acl
.
Acceptable values are:
|
Request body
Do not supply a request body with this method.
Response
If successful, this method returns a response body with the following structure:
{ "kind": "storage#objects", "nextPageToken": string, "prefixes": [ string ], "items": [ objects Resource ] }
Property name | Value | Description | Notes |
---|---|---|---|
kind
|
string
|
The kind of item this is. For lists of objects, this is always
storage#objects
.
|
|
nextPageToken
|
string
|
The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results. | |
prefixes[]
|
list
|
The list of prefixes of objects matching-but-not-listed up to and including the requested delimiter. | |
items[]
|
list
|
The list of items. |
Examples
Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).
Ruby
Uses the Ruby client library
# List all objects in a bucket objects_list_result = client.execute( api_method: storage.objects.list, parameters: {bucket: BUCKET} ) puts "List of objects in #{BUCKET}: "
objects_list_result.data.items.each { |item| puts item.name }
Try it!
Use the APIs Explorer below to call this method on live data and see the response. Alternatively, try the standalone Explorer .