i can upload images from Android to Amazon s3. But they are always private, no one can display them. i have to make it public on Amazon s3 management console. i can not set ACL for an image while uploading it.
I learned that, there are two ways to upload image to Amazon s3 from Android:
- using PutObjectRequest
- using TransferUtility.upload()
i tried both. if i prefer PutObjectRequest, i have to use AsyncTask or another thread. Because PutObjectRequest runs on main thread. But i do not want to use AsyncTask or another thread.
i want to use TransferUtility, because it does not run on main thread, works on service, so i do not have to use AsyncTask or another thread. Also i can track progress and state of transfer easily. In addition, TransferUtility is newer than PubObjectRequest. But the problem comes here: i do not know how to set ACL for an object while or before uploading it to s3. i tried that :
s3Client.setObjectAcl("myBucket", "steve_jobs.jpg", CannedAccessControlList.PublicRead);
but it returned "network on main thread" error. So i need to use AsyncTask or another thread.but i do not want to use AsyncTask or another thread. how can i set ACL for an object while uploading it with TransferUtility?