From c2a4f0bd0462bf7853ba59f858fb5e3d1a85855a Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Mon, 29 Aug 2022 14:42:37 -0700 Subject: [PATCH] get bucket list --- .../page/s3manager/BucketSelect.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/asgardius/page/s3manager/BucketSelect.java b/app/src/main/java/asgardius/page/s3manager/BucketSelect.java index f189641..72ee17a 100644 --- a/app/src/main/java/asgardius/page/s3manager/BucketSelect.java +++ b/app/src/main/java/asgardius/page/s3manager/BucketSelect.java @@ -13,6 +13,10 @@ import com.amazonaws.regions.Region; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.S3ClientOptions; +import com.amazonaws.services.s3.model.Bucket; + +import java.util.ArrayList; +import java.util.List; public class BucketSelect extends AppCompatActivity { @@ -38,7 +42,20 @@ public class BucketSelect extends AppCompatActivity { @Override protected String doInBackground(String[] params) { // do above Server call here - System.out.println(s3client.listBuckets()); + //This get bucket list + List buckets = s3client.listBuckets(); + //This convert bucket list to an array list + List bucketList = new ArrayList(); + // Print bucket names + //System.out.println("Buckets:"); + int i=0; + for (Bucket bucket : buckets) { + //i++; + //System.out.println(bucket.getName()); + bucketList.add(bucket.getName()); + } + System.out.println(bucketList); + //System.out.println(s3client.listBuckets().toArray()); return "some message"; }