选择您的 Cookie 首选项

我们使用必要 Cookie 和类似工具提供我们的网站和服务。我们使用性能 Cookie 收集匿名统计数据,以便我们可以了解客户如何使用我们的网站并进行改进。必要 Cookie 无法停用,但您可以单击“自定义”或“拒绝”来拒绝性能 Cookie。

如果您同意,AWS 和经批准的第三方还将使用 Cookie 提供有用的网站功能、记住您的首选项并显示相关内容,包括相关广告。要接受或拒绝所有非必要 Cookie,请单击“接受”或“拒绝”。要做出更详细的选择,请单击“自定义”。

ListBuckets - Amazon Simple Storage Service
此页面尚未翻译为您的语言。 请求翻译

ListBuckets

Note

This operation is not supported for directory buckets.

Returns a list of all buckets owned by the authenticated sender of the request. To grant IAM permission to use this operation, you must add the s3:ListAllMyBuckets policy action.

For information about Amazon S3 buckets, see Creating, configuring, and working with Amazon S3 buckets.

Important

We strongly recommend using only paginated ListBuckets requests. Unpaginated ListBuckets requests are only supported for AWS accounts set to the default general purpose bucket quota of 10,000. If you have an approved general purpose bucket quota above 10,000, you must send paginated ListBuckets requests to list your account’s buckets. All unpaginated ListBuckets requests will be rejected for AWS accounts with a general purpose bucket quota greater than 10,000.

Request Syntax

GET /?bucket-region=BucketRegion&continuation-token=ContinuationToken&max-buckets=MaxBuckets&prefix=Prefix HTTP/1.1 Host: s3.amazonaws.com

URI Request Parameters

The request uses the following URI parameters.

bucket-region

Limits the response to buckets that are located in the specified AWS Region. The AWS Region must be expressed according to the AWS Region code, such as us-west-2 for the US West (Oregon) Region. For a list of the valid values for all of the AWS Regions, see Regions and Endpoints.

Note

Requests made to a Regional endpoint that is different from the bucket-region parameter are not supported. For example, if you want to limit the response to your buckets in Region us-west-2, the request must be made to an endpoint in Region us-west-2.

continuation-token

ContinuationToken indicates to Amazon S3 that the list is being continued on this bucket with a token. ContinuationToken is obfuscated and is not a real key. You can use this ContinuationToken for pagination of the list results.

Length Constraints: Minimum length of 0. Maximum length of 1024.

Required: No.

Note

If you specify the bucket-region, prefix, or continuation-token query parameters without using max-buckets to set the maximum number of buckets returned in the response, Amazon S3 applies a default page size of 10,000 and provides a continuation token if there are more buckets.

max-buckets

Maximum number of buckets to be returned in response. When the number is more than the count of buckets that are owned by an AWS account, return all the buckets in response.

Valid Range: Minimum value of 1. Maximum value of 10000.

prefix

Limits the response to bucket names that begin with the specified bucket name prefix.

Request Body

The request does not have a request body.

Response Syntax

HTTP/1.1 200 <?xml version="1.0" encoding="UTF-8"?> <ListAllMyBucketsResult> <Buckets> <Bucket> <BucketRegion>string</BucketRegion> <CreationDate>timestamp</CreationDate> <Name>string</Name> </Bucket> </Buckets> <Owner> <DisplayName>string</DisplayName> <ID>string</ID> </Owner> <ContinuationToken>string</ContinuationToken> <Prefix>string</Prefix> </ListAllMyBucketsResult>

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in XML format by the service.

ListAllMyBucketsResult

Root level tag for the ListAllMyBucketsResult parameters.

Required: Yes

Buckets

The list of buckets owned by the requester.

Type: Array of Bucket data types

ContinuationToken

ContinuationToken is included in the response when there are more buckets that can be listed with pagination. The next ListBuckets request to Amazon S3 can be continued with this ContinuationToken. ContinuationToken is obfuscated and is not a real bucket.

Type: String

Owner

The owner of the buckets listed.

Type: Owner data type

Prefix

If Prefix was sent with the request, it is included in the response.

All bucket names in the response begin with the specified bucket name prefix.

Type: String

Examples

Example 1: Unpaginated ListBuckets request

This example lists all the buckets in your account in a single unpaginated response. Unpaginated requests are only supported for AWS accounts that have the default service quota of 10,000 buckets. If you have an approved general purpose bucket quota that is greater than 10,000 buckets, all unpaginated requests will be rejected for your account.

GET / host:s3.us-east-2.amazonaws.com
HTTP/1.1 200 OK <ListAllMyBucketsResult> <Buckets> <Bucket> <CreationDate>2019-12-11T23:32:47+00:00</CreationDate> <Name>amzn-s3-demo-bucket</Name> </Bucket> <Bucket> <CreationDate>2019-11-10T23:32:13+00:00</CreationDate> <Name>amzn-s3-demo-bucket1</Name> </Bucket> </Buckets> <Owner> <DisplayName>Account+Name</DisplayName> <ID>AIDACKCEVSQ6C2EXAMPLE</ID> </Owner> </ListAllMyBucketsResult>

Example 2: Paginated ListBuckets request

The following example request lists all buckets in your account using pagination. It gets the first page of results with the page size set to 1000 buckets. The response returns a ContinuationToken that is used in Example 3 to list the next 1000 buckets.

GET / max-buckets=1000 host:s3.us-east-2.amazonaws.com
HTTP/1.1 200 OK <ListAllMyBucketsResult> <Buckets> <Bucket> <CreationDate>2024-11-14T23:32:47+00:00</CreationDate> <Name>amzn-s3-demo-bucket</Name> <BucketRegion>us-east-1</BucketRegion> </Bucket> <Bucket> <CreationDate>2024-11-14T23:32:13+00:00</CreationDate> <Name>amzn-s3-demo-bucket1</Name> <BucketRegion>us-east-2</BucketRegion> </Bucket> </Buckets> <Owner> <DisplayName>Account+Name</DisplayName> <ID>AIDACKCEVSQ6C2EXAMPLE</ID> </Owner> <ContinuationToken>eyJNYXJrZXIiOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAxfQ==</ContinuationToken> </ListAllMyBucketsResult>

Example 3: Paginated ListBuckets request with continuation token

This example request uses the token returned in Example 2 to return the next 1000 buckets. Continue until there are no more results. If you do not receive a continuation token with your initial paginated ListBuckets request, then your single paginated request returned all of the buckets in your account.

GET / max-buckets=1000&continuation-token=eyJNYXJrZXIiOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAxfQ== host:s3.us-east-2.amazonaws.com
HTTP/1.1 200 OK <ListAllMyBucketsResult> <Buckets> <Bucket> <CreationDate>2024-11-14T23:32:47+00:00</CreationDate> <Name>amzn-s3-demo-bucket</Name> <BucketRegion>us-east-1</BucketRegion> </Bucket> <Bucket> <CreationDate>2024-11-14T23:32:13+00:00</CreationDate> <Name>amzn-s3-demo-bucket1</Name> <BucketRegion>us-east-2</BucketRegion> </Bucket> </Buckets> <Owner> <DisplayName>Account+Name</DisplayName> <ID>AIDACKCEVSQ6C2EXAMPLE</ID> </Owner> <ContinuationToken>eyJOZXh0VG9rZW4iOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiEXAMPLE=</ContinuationToken> </ListAllMyBucketsResult>

Example 4: Paginated ListBuckets request for buckets in US East (Ohio) (us-east-2)

The following example lists all the buckets in your account in the us-east-2 Region. The first paginated response will return up to 1000 buckets. Requests made to a Regional endpoint that is different from the bucket-region parameter are not supported.

GET / bucket-region=us-east-2&max-buckets=1000 host:s3.us-east-2.amazonaws.com
HTTP/1.1 200 OK <ListAllMyBucketsResult> <Buckets> <Bucket> <CreationDate>2024-11-14T23:32:47+00:00</CreationDate> <Name>DOC-EXAMPLE-BUCKET</Name> <BucketRegion>us-east-2</BucketRegion> </Bucket> <Bucket> <CreationDate>2024-11-14T23:32:13+00:00</CreationDate> <Name>DOC-EXAMPLE-BUCKET1002</Name> <BucketRegion>us-east-2</BucketRegion> </Bucket> </Buckets> <Owner> <DisplayName>Account+Name</DisplayName> <ID>AIDACKCEVSQ6C2EXAMPLE</ID> </Owner> <ContinuationToken>eyJOZXh0VG9rZW4iOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiEXAMPLEcd =</ContinuationToken> </ListAllMyBucketsResult>

Example 5: Paginated ListBuckets request for buckets in your account that begin with amzn-s3-demo-bucket in US East (Ohio) (us-east-2)

The following example lists all the buckets in your account located in the us-east-2 Region that begin with the amzn-s3-demo-bucket bucket prefix. This request uses pagination.

GET / bucket-region=us-east-2&max-buckets=1000&prefix=amzn-s3-demo-bucket host:s3.us-east-2.amazonaws.com
HTTP/1.1 200 OK <ListAllMyBucketsResult> <Buckets> <Bucket> <CreationDate>2024-11-14T23:32:47+00:00</CreationDate> <Name>amzn-s3-demo-bucket</Name> <BucketRegion>us-east-2</BucketRegion> </Bucket> <Bucket> <CreationDate>2024-11-14T23:32:13+00:00</CreationDate> <Name>DOC-EXAMPLE-BUCKET1002</Name> <BucketRegion>us-east-2</BucketRegion> </Bucket> </Buckets> <Owner> <DisplayName>Account+Name</DisplayName> <ID>AIDACKCEVSQ6C2EXAMPLE</ID> </Owner> <Prefix> amzn-s3-demo-bucket </Prefix> <ContinuationToken>eyJOZXh0VG9rZW4iOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiEXAMPLE=</ContinuationToken> </ListAllMyBucketsResult>

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

隐私网站条款Cookie 首选项
© 2025, Amazon Web Services, Inc. 或其附属公司。保留所有权利。