From 2ab9181a7c6ba2c419dba1cf85c764689274fc33 Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Thu, 8 Sep 2022 03:46:20 -0700 Subject: [PATCH] fix aws issue --- .idea/deploymentTargetDropDown.xml | 17 --------- .../page/s3manager/ObjectSelect.java | 38 ++++++++++++++++++- 2 files changed, 37 insertions(+), 18 deletions(-) delete mode 100644 .idea/deploymentTargetDropDown.xml diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index 664ece3..0000000 --- a/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java index 959acc3..9766c32 100644 --- a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java +++ b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java @@ -1,6 +1,7 @@ package asgardius.page.s3manager; import static com.amazonaws.regions.Regions.US_EAST_1; +import static com.amazonaws.regions.Regions.US_WEST_1; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; @@ -40,7 +41,7 @@ public class ObjectSelect extends AppCompatActivity { ArrayList Img; //ArrayList object; RecyclerView recyclerView; - String username, password, endpoint, bucket, prefix; + String username, password, endpoint, bucket, prefix, location; int treelevel; String[] filename, path; @@ -63,6 +64,41 @@ public class ObjectSelect extends AppCompatActivity { AmazonS3 s3client = new AmazonS3Client(myCredentials, region); s3client.setEndpoint(endpoint); s3client.setS3ClientOptions(s3ClientOptions); + if (endpoint.contains(getResources().getString(R.string.aws_endpoint))) { + Thread getlocation = new Thread(new Runnable() { + + @Override + public void run() { + try { + //Your code goes here + location = s3client.getBucketLocation(bucket); + System.out.println(location); + Region region = Region.getRegion(location); + s3client.setRegion(region); + + } catch (Exception e) { + e.printStackTrace(); + runOnUiThread(new Runnable() { + + @Override + public void run() { + Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); + } + }); + //Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); + finish(); + } + } + }); + getlocation.start(); + try { + getlocation.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + } + recyclerView = findViewById(R.id.olist); final ProgressBar simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar);