Skip to content

Commit

Permalink
fixed a ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
scmacdon authored and meyertst-aws committed Jan 29, 2024
1 parent 5c02c03 commit be6de2c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .doc_gen/metadata/s3_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1971,6 +1971,15 @@ s3_ListBuckets:
synopsis: list S3 buckets.
category:
languages:
Java:
versions:
- sdk_version: 2
github: javav2/example_code/s3
sdkguide:
excerpts:
- description:
snippet_tags:
- s3.java2.list.buckets.main
.NET:
versions:
- sdk_version: 3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*SPDX-License-Identifier:Apache-2.0*/

package com.example.s3;

// snippet-start:[s3.java2.getobjecturl.main]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package com.example.s3;

// snippet-start:[s3.java2.list.buckets.main]
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.Bucket;
import software.amazon.awssdk.services.s3.model.ListBucketsResponse;
import java.util.List;

/**
* Before running this Java V2 code example, set up your development
* environment, including your credentials.
*
* For more information, see the following documentation topic:
*
* https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
*/
public class ListBuckets {
public static void main(String[] args) {
Region region = Region.US_EAST_1;
S3Client s3 = S3Client.builder()
.region(region)
.build();

listAllBuckets(s3);

}
public static void listAllBuckets(S3Client s3) {
ListBucketsResponse response = s3.listBuckets();
List<Bucket> bucketList = response.buckets();
for (Bucket bucket: bucketList) {
System.out.println("Bucket name "+bucket.name());
}
}
}
// snippet-end:[s3.java2.list.buckets.main]

0 comments on commit be6de2c

Please sign in to comment.