Relsell
Relsell

Reputation: 771

AWS Android SDK app for S3 Transfer Utility is raising exception while reading

I have created a AWS S3 bucket. and I am able to access bucket using https://github.com/awslabs/aws-sdk-android-samples/blob/master/S3TransferUtilitySample/S3TransferUtilityTutorial.md , TransferUtility SDK app provide by amazon.

I made some changes regarding the configuration of respective Region and bucket name and then I was able to connect to S3.

I am having proper permission to read / write S3 Bucket as provided to me by Server Admin. I successfully upload two images to S3 bucket using code. I can now see two image files are present in S3.

Now when I try to download these file I get exeception as

com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: 04800521FBB752B0)

I have read and write permissions but still getting this exception. Is it related to permission only or I am missing something.

Thanks in advance.

Upvotes: 4

Views: 1184

Answers (3)

vaquar khan
vaquar khan

Reputation: 11449

Amazon S3 will return an AccessDenied error when a nonexistent key is requested and the requester is not allowed to list the contents of the bucket.

Using AWS SDKs to Obtain Request IDs

The following sections include information for configuring logging using an AWS SDK. While you can enable verbose logging on every request and response, you should not enable logging in production systems since large requests/responses can cause significant slow down in an application.

Troubleshooting

1) First check I AM role, your permissions ,Go to IAM and check whether the user [ Access Key & Secret Key ] which is being used for the API has the privileges to use S3 Based API.

2 Verify that your access key still has access to S3 resources and that bucket.

3) Verify that by attempting the same action using the AWS CL.

4) Use the AWS iam get-user command to show the current user, if it's diffrent user will get this error.

{ "User": { "UserName": "MY_DEFAULT_USER_NAME", "PasswordLastUsed": "2017-03-15T01:59:05Z", "CreateDate": "2016-04-30T02:46:19Z", "UserId": "ABCDEFGHIJKLMNOPQ", "Path": "/", "Arn": "arn:aws:iam::123456789:user/MY_DEFAULT_USER_NAME" } } 

5) Check your environment variable may be AWS keys in my environment variables are diffrent.

6) For AWS SDK troubleshooting requests, the pair of request IDs will look like the following examples.

status Code: 403, AWS Service: Amazon S3, AWS Request ID: 79104EXAMPLEB723  
AWS Error Code: AccessDenied  AWS Error Message: Access Denied  
S3 Extended Request ID: IOWQ4fDEXAMPLEQM+ey7N9WgVhSnQ6JEXAMPLEZb7hSQDASK+Jd1vEXAMPLEa3Km

7) Check The end point is correct in code , There should be a correct end point.

Upvotes: 0

Relsell
Relsell

Reputation: 771

There was a problem with previous conginto pool id , i think it was having some permissions issues.

We changed cognito pool ID and then it worked properly.

Upvotes: 0

MarkySmarky
MarkySmarky

Reputation: 1629

I think there's another permissions for downloading. You need to set who can download this file - read is not enough. Right click on the file in your S3 bucket and checkout the permissions section - you'll see it there.

Upvotes: 3

Related Questions