All Products
Search
Document Center

Object Storage Service:list-objects (get-bucket)

Last Updated:Jan 13, 2025

Lists all objects in the specified Object Storage Service (OSS) bucket.

Usage notes

  • By default, an Alibaba Cloud account has the permissions to list all objects in a bucket. To list all objects in a bucket by using a RAM user or Security Token Service (STS), you must have the oss:ListObjects permission. For more information, see Attach a custom policy to a RAM user.

  • The list-objects (get-bucket) command has been updated to a newer version: list-objects-v2 (get-bucket-v2). We recommend that you use list-objects-v2 (get-bucket-v2) in your application development. To maintain backward compatibility, OSS continues to support the list-objects (get-bucket) command.

  • The list-objects (get-bucket) command does not return user metadata of objects.

Command syntax

ossutil api list-objects --bucket value [flags]

Parameter

Type

Description

--bucket

string

The name of the bucket.

--delimiter

string

The character that you want to use to group objects by name.

--encoding-type

string

The encoding type of the object names in the response.

--marker

string

The name of the object after which the list-objects operation starts. If this parameter is specified, objects whose names are alphabetically after the value of marker are returned.

--max-keys

int

The maximum number of objects to return.

--prefix

string

The prefix that the returned object names must contain.

Note
  • The list-objects command is the equivalent of the GetBucket (ListObjects) operation. For more information about the API operation, see GetBucket (ListObjects).

  • For more information about supported global command-line options, see Command-line options.

Examples

List all objects in a bucket named examplebucket.

ossutil api list-objects --bucket examplebucket

List all objects in a bucket named examplebucket and format the output in JSON.

ossutil api list-objects --bucket examplebucket --output-format json

List all objects in a bucket named examplebucket and format the output in YAML.

ossutil api list-objects --bucket examplebucket --output-format yaml

List all objects with the dir prefix in their names in a bucket named examplebucket.

ossutil api list-objects --bucket examplebucket --prefix dir

List the first 100 objects with the dir prefix in their names in a bucket named examplebucket.

ossutil api list-objects --bucket examplebucket --prefix dir --max-keys 100

List all objects in the current directory in a bucket named examplebucket.

ossutil api list-objects --bucket examplebucket --delimiter /

List objects whose names are alphabetically after test.txt in a bucket named examplebucket.

ossutil api list-objects --bucket examplebucket --marker test.txt

List all objects in a bucket named examplebucket and URL-encode object names in the response.

ossutil api list-objects --bucket examplebucket --encoding-type url