How To Upload An Android File To S3 Bucket With Public Permission
I keep trying to upload a file to an s3 bucket. But the file is never public for viewing. I have to manually make the files/folder in the bucket public (for every upload) for it to
Solution 1:
Yes, it is very easy for those guys, who is using TransferUtility, use below method for uploading any file for public readable form using TransferUtility in android,
transferUtility.upload(String bucketName,Stringkey,File file,CannedAccessControlList cannedAcl)
Example:
transferUtility.upload("MY_BUCKET_NAME","FileName",your_file,CannedAccessControlList.PublicRead);
Solution 2:
To make all objects in your bucket public by default, view the answers to this question or this question.
To specify public access for each file when you are uploading them via Android, set the ACL on the PutObjectRequest
like this:
PutObjectRequestputObjectRequest=newPutObjectRequest()
.withCannedAcl(CannedAccessControlList.PublicRead)
It doesn't look like you can set the ACL in one step with TransferUtility
at this time: https://github.com/aws/aws-sdk-android/issues/63
So after uploading the file via TransferUtility
you would need to do the following:
s3client.setObjectAcl(bucketName, keyName, CannedAccessControlList.PublicRead);
Post a Comment for "How To Upload An Android File To S3 Bucket With Public Permission"