List buckets of a region (Amazon S3) #920

Closed
linerdong opened this Issue Nov 14, 2016 · 8 comments

Comments

Projects
None yet
4 participants
@linerdong

I want to list the bucket of one region. Now I can list bucket of global by client.listbuckets() and then check the region of the bucket by client.getBucketLocation. But this way will lost much time if there are too many buckets .

Can you provide a function to list buckets of a region, or add an attribute in com.amazonaws.services.s3.model.Bucket, and I can check the region wichout new connection.

@KumareshBabuNS

This comment has been minimized.

Show comment
Hide comment
@KumareshBabuNS

KumareshBabuNS Nov 14, 2016

You need to mention s3 endpoint in java code

You need to mention s3 endpoint in java code

@linerdong

This comment has been minimized.

Show comment
Hide comment
@linerdong

linerdong Nov 14, 2016

mention s3 endpoint in client.listbuckets()? I find listbuckets has only one paramete ListBucketsRequest, and how to set the s3 endpoint in this parameter?

mention s3 endpoint in client.listbuckets()? I find listbuckets has only one paramete ListBucketsRequest, and how to set the s3 endpoint in this parameter?

@KumareshBabuNS

This comment has been minimized.

Show comment
Hide comment
@KumareshBabuNS

KumareshBabuNS Nov 14, 2016

Try this code s3.setEndpoint(String endpoint) method. s3 is an object for AmazonS3Client class.

Try this code s3.setEndpoint(String endpoint) method. s3 is an object for AmazonS3Client class.

@KumareshBabuNS

This comment has been minimized.

Show comment
Hide comment
@linerdong

This comment has been minimized.

Show comment
Hide comment
@linerdong

linerdong Nov 14, 2016

I try:
AWSCredentials credentials = new BasicAWSCredentials(accessKey,
secretKey);
AmazonS3 client = new AmazonS3Client(credentials);
client.setEndpoint("s3-ap-southeast-1.amazonaws.com")
client.listbuckets();

but it still list all buckets of global.

I try:
AWSCredentials credentials = new BasicAWSCredentials(accessKey,
secretKey);
AmazonS3 client = new AmazonS3Client(credentials);
client.setEndpoint("s3-ap-southeast-1.amazonaws.com")
client.listbuckets();

but it still list all buckets of global.

@KumareshBabuNS

This comment has been minimized.

Show comment
Hide comment
@KumareshBabuNS

KumareshBabuNS Nov 14, 2016

We can't create bucket in specific region. Once you are trying to create an bucket it will ask for region that is endpoint in java code.
In AWS Console, It shows S3 is global.
In Java code, use https://s3-ap-southeast-1.amazonaws.com. Use getBucketLocation(String bucketName) method. Refer this documentation

We can't create bucket in specific region. Once you are trying to create an bucket it will ask for region that is endpoint in java code.
In AWS Console, It shows S3 is global.
In Java code, use https://s3-ap-southeast-1.amazonaws.com. Use getBucketLocation(String bucketName) method. Refer this documentation

@spfink

This comment has been minimized.

Show comment
Hide comment
@spfink

spfink Nov 16, 2016

Contributor

It is not possible to list the buckets in a single region. Regardless of the endpoint or region that you set, when calling list buckets you will get buckets from all regions.

In order to determine the region of a bucket you can use getBucketLocation(String bucketName).

https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3.java#L1026

Contributor

spfink commented Nov 16, 2016

It is not possible to list the buckets in a single region. Regardless of the endpoint or region that you set, when calling list buckets you will get buckets from all regions.

In order to determine the region of a bucket you can use getBucketLocation(String bucketName).

https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3.java#L1026

@zhangzhx

This comment has been minimized.

Show comment
Hide comment
@zhangzhx

zhangzhx Nov 30, 2016

Contributor

Closing this issue for not hearing back for 2 weeks. Feel free to reopen it if you still have problem.

Contributor

zhangzhx commented Nov 30, 2016

Closing this issue for not hearing back for 2 weeks. Feel free to reopen it if you still have problem.

@zhangzhx zhangzhx closed this Nov 30, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment