Skip to content

Instantly share code, notes, and snippets.

@mihirsane
Last active January 29, 2020 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mihirsane/4be937e53d20b406293c4e2e2539f6a1 to your computer and use it in GitHub Desktop.
Save mihirsane/4be937e53d20b406293c4e2e2539f6a1 to your computer and use it in GitHub Desktop.
S3FileTranfer
public static TransferUtility getS3TransferUtility(String fileName,File file){
AmazonS3Client s3client = new AmazonS3Client(new AWSCredentials() {
@Override
public String getAWSAccessKeyId() {
return App.ACCESS_KEY;
}
@Override
public String getAWSSecretKey() {
return App.SECRET_KEY;
}
});
s3client.setRegion(Region.getRegion(Regions.AP_SOUTHEAST_2));
TransferUtility transferUtility =
TransferUtility.builder()
.context(context)
.awsConfiguration(AWSMobileClient.getInstance().getConfiguration())
.defaultBucket(App.BUCKET_NAME)
.s3Client(s3client)
.build();
TransferObserver uploadObserver =
getS3TransferUtility().upload(
fileName,
file);
return transferUtility;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment