Reputation: 1268
I am trying to upload an image to my AWS bucket I had created a new user Granted him fulls3 control
AWSCredentials credentials = new BasicAWSCredentials(MY_ACCESS_KEY_ID, MY_SECRET_KEY);
AmazonS3 s3client = new AmazonS3Client(credentials);
PutObjectResult objectRequest = s3client.putObject(new PutObjectRequest(GlobalConstant.bucketName+"/testing", f.getName().toString(),
f));
but while uploading I am getting below error:
05-27 07:09:47.219: W/System.err(20594): com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: ), S3 Extended Request ID: +++/=
Upvotes: 0
Views: 3187
Reputation: 512
Please check the credentials files under the ~/.aws directory. Please ensure that the iam user, you are using has the right to s3 buckets ensuring that it has the PutObject policy attached to it.
Once the iam user has the "PutObject" policy attached to the iam user. you should be able to run it correctly.
Upvotes: 0
Reputation: 802
Are you sure the user you created (IAM I'm assuming?) is the same as the credentials you are using?
You might want to checkout using the S3 Transfer Manager as it makes downloading/uploading to S3 a lot easier, and gives you the ability to pause/resume downloads.
I strongly recommend using temporary credentials for a mobile application, as embedding credentials is never safe.
There is a getting started guide for both of these http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/getting-started-store-retrieve-s3.html
Upvotes: 0
Reputation: 511
Run aws configure
command and fill in all the configuration details.
In Management console, Select bucket and select properties tab. Click add more permissions. Grantee select username from drop down, check list, upload/delete. For testing purpose you can set permission to Everyone and check all options.
Upvotes: 0