简体   繁体   中英

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.

You need to use PutObjectRequest in upload() .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM