Created
March 18, 2018 13:36
-
-
Save BarisGece/6f84076bbc2c10362d88b895b6ba4982 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//AWS SDK 1.x.x | |
final PutObjectRequest putRequest = new PutObjectRequest(s3bucket, targetDirectory + “/” + file.getName(), file).withCannedAcl(CannedAccessControlList.PublicRead); | |
final Upload upload = transferManager.upload(putRequest); | |
//AWS SDK 2.0 — with ContentType | |
String fileType = Files.probeContentType(file); | |
final S3Client s3client; | |
s3client.putObject(PutObjectRequest.builder().bucket(s3bucket).key(targetDirectory + FileSystems.getDefault().getSeparator() + file.getFileName()).acl(ObjectCannedACL.PUBLIC_READ).contentType(fileType).build(),RequestBody.of(file)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment