s3client code cleanup
This commit is contained in:
parent
9aa06a1339
commit
9b434a1ce0
2 changed files with 15 additions and 5 deletions
|
@ -30,13 +30,16 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
String endpoint = getIntent().getStringExtra("endpoint");
|
||||||
|
String username = getIntent().getStringExtra("username");
|
||||||
|
String password = getIntent().getStringExtra("password");
|
||||||
setContentView(R.layout.activity_bucket_select);
|
setContentView(R.layout.activity_bucket_select);
|
||||||
Region region = Region.getRegion(US_EAST_1);
|
Region region = Region.getRegion(US_EAST_1);
|
||||||
S3ClientOptions s3ClientOptions = S3ClientOptions.builder().build();
|
S3ClientOptions s3ClientOptions = S3ClientOptions.builder().build();
|
||||||
s3ClientOptions.setPathStyleAccess(true);
|
s3ClientOptions.setPathStyleAccess(true);
|
||||||
AWSCredentials myCredentials = new BasicAWSCredentials(getResources().getString(R.string.access_key), getResources().getString(R.string.secret_key));
|
AWSCredentials myCredentials = new BasicAWSCredentials(username, password);
|
||||||
s3client = new AmazonS3Client(myCredentials, region);
|
AmazonS3 s3client = new AmazonS3Client(myCredentials, region);
|
||||||
s3client.setEndpoint(getResources().getString(R.string.endpoint_url));
|
s3client.setEndpoint(endpoint);
|
||||||
s3client.setS3ClientOptions(s3ClientOptions);
|
s3client.setS3ClientOptions(s3ClientOptions);
|
||||||
|
|
||||||
recyclerView = findViewById(R.id.recyclerview);
|
recyclerView = findViewById(R.id.recyclerview);
|
||||||
|
|
|
@ -24,11 +24,15 @@ import java.net.URL;
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
static boolean DEFAULT_PATH_STYLE_ACCESS = true;
|
static boolean DEFAULT_PATH_STYLE_ACCESS = true;
|
||||||
|
String username, password, endpoint;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
username = getString(R.string.access_key);
|
||||||
|
password = getResources().getString(R.string.secret_key);
|
||||||
|
endpoint = getResources().getString(R.string.endpoint_url);
|
||||||
//This is to launch video playback test
|
//This is to launch video playback test
|
||||||
Button videotest = (Button)findViewById(R.id.vtest);
|
Button videotest = (Button)findViewById(R.id.vtest);
|
||||||
videotest.setOnClickListener(new View.OnClickListener(){
|
videotest.setOnClickListener(new View.OnClickListener(){
|
||||||
|
@ -57,9 +61,9 @@ public class MainActivity extends AppCompatActivity {
|
||||||
Region region = Region.getRegion(US_EAST_1);
|
Region region = Region.getRegion(US_EAST_1);
|
||||||
S3ClientOptions s3ClientOptions = S3ClientOptions.builder().build();
|
S3ClientOptions s3ClientOptions = S3ClientOptions.builder().build();
|
||||||
s3ClientOptions.setPathStyleAccess(true);
|
s3ClientOptions.setPathStyleAccess(true);
|
||||||
AWSCredentials myCredentials = new BasicAWSCredentials(getResources().getString(R.string.access_key), getResources().getString(R.string.secret_key));
|
AWSCredentials myCredentials = new BasicAWSCredentials(username, password);
|
||||||
AmazonS3 s3client = new AmazonS3Client(myCredentials, region);
|
AmazonS3 s3client = new AmazonS3Client(myCredentials, region);
|
||||||
s3client.setEndpoint(getResources().getString(R.string.endpoint_url));
|
s3client.setEndpoint(endpoint);
|
||||||
s3client.setS3ClientOptions(s3ClientOptions);
|
s3client.setS3ClientOptions(s3ClientOptions);
|
||||||
//s3client.setRegion(getRegion("asteroid"));
|
//s3client.setRegion(getRegion("asteroid"));
|
||||||
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(getResources().getString(R.string.bucketname), getResources().getString(R.string.objectname));
|
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(getResources().getString(R.string.bucketname), getResources().getString(R.string.objectname));
|
||||||
|
@ -78,6 +82,9 @@ public class MainActivity extends AppCompatActivity {
|
||||||
private void explorer() {
|
private void explorer() {
|
||||||
|
|
||||||
Intent intent = new Intent(this, BucketSelect.class);
|
Intent intent = new Intent(this, BucketSelect.class);
|
||||||
|
intent.putExtra("endpoint", endpoint);
|
||||||
|
intent.putExtra("username", username);
|
||||||
|
intent.putExtra("password", password);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue