Siri
Siri

Reputation: 701

How do you make an S3 object public via the aws SDK Android?

I need to make my upload as public. I was able to upload a image into s3 bucket. But i was unable to make that public by programmatically I am using AWS SDK 2.1.10 Below is my code for uploading image into s3 bucket

mUpload = getTransferManager().upload( AmazonConstants.BUCKET_NAME.toLowerCase(Locale.US), /* getPrefix(getContext()) // "android_uploads/" */ locationPath + super.getFileName() /** + "." + mExtension */ , mFile); 

mUpload.waitForCompletion();

Please help me. Thank you.

Upvotes: 1

Views: 1438

Answers (1)

inmyth
inmyth

Reputation: 9050

You need to use PutObjectRequest in upload().

getTransferManager().upload(
    new PutObjectRequest(String bucketName, String key, File file)
   .withCannedAcl(CannedAccessControlList.PublicRead)
); 

Upvotes: 4

Related Questions