public void uploadDocuments (List filesToUpload) throws AmazonServiceException, AmazonClientException, InterruptedException {AmazonS3 s3 = AmazonS3ClientBuilder.standard (). WithCredentials (getCredentials ()). WithRegion (Regions.AP_SOUTH_1) .build ();
TransferManager transfer = TransferManagerBuilder.standard().withS3Client(s3).build(); String bucket = Constants.BUCKET_NAME; MultipleFileUpload upload = transfer.uploadFileList(bucket, "", new File("."), filesToUpload); upload.waitForCompletion(); } private AWSCredentialsProvider getCredentials() { String accessKey = Constants.ACCESS_KEY; String secretKey = Constants.SECRET_KEY; BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey); return new AWSStaticCredentialsProvider(awsCredentials); }
source share