fix aws issue

This commit is contained in:
Page Asgardius 2022-09-08 03:46:20 -07:00
parent c532ddaa1a
commit 2ab9181a7c
2 changed files with 37 additions and 18 deletions

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="$USER_HOME$/.android/avd/4.7_WXGA_API_31.avd" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-09-08T02:24:30.038432Z" />
</component>
</project>

View file

@ -1,6 +1,7 @@
package asgardius.page.s3manager; package asgardius.page.s3manager;
import static com.amazonaws.regions.Regions.US_EAST_1; 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.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
@ -40,7 +41,7 @@ public class ObjectSelect extends AppCompatActivity {
ArrayList Img; ArrayList Img;
//ArrayList object; //ArrayList object;
RecyclerView recyclerView; RecyclerView recyclerView;
String username, password, endpoint, bucket, prefix; String username, password, endpoint, bucket, prefix, location;
int treelevel; int treelevel;
String[] filename, path; String[] filename, path;
@ -63,6 +64,41 @@ public class ObjectSelect extends AppCompatActivity {
AmazonS3 s3client = new AmazonS3Client(myCredentials, region); AmazonS3 s3client = new AmazonS3Client(myCredentials, region);
s3client.setEndpoint(endpoint); s3client.setEndpoint(endpoint);
s3client.setS3ClientOptions(s3ClientOptions); 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); recyclerView = findViewById(R.id.olist);
final ProgressBar simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar); final ProgressBar simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar);