I have been stuck on this for ages. I see others have had the same problem, but I cannot fix it.
I am developing an Android app, which takes a picture from the camera, and uploads it the a bucket on Amazon S3. Here is my code:
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
getApplicationContext(), /* get the context for the application */
"MY_POOL_ID", /* Identity Pool ID */
Regions.US_EAST_1 /* Region for your identity pool--US_EAST_1 or EU_WEST_1*/
);
// Create an S3 client
AmazonS3 s3 = new AmazonS3Client(credentialsProvider);
s3.setRegion(Region.getRegion(Regions.US_EAST_1));
TransferUtility transferUtility = new TransferUtility(s3, getApplicationContext());
TransferObserver observer = transferUtility.upload(
MY_BUCKET, /* The bucket to upload to */
OBJECT_KEY, /* The key for the uploaded object */
f /* The file where the data to upload exists */
);
I have created a bucket. The file f
, I converted a Bitmap from the camera to a file. My Pool ID works, if I change it I get an error pool not found
; same with the bucket. However every time I try to upload I get this error:
Failed to upload: 11 due to Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: FD1B30F)
I am a beginner with Amazon S3, and I am following their instructions again and again, but I cannot fix this.
I have this in manifest:
<service
android:name="com.amazonaws.mobileconnectors.s3.transferutility.TransferService"
android:enabled="true" />
and the correct permissions.
What do I need to do to correct this?