Create bucket
Eg: aws_upload_test
Create
Manage Identity Pools
Create New Identity Pool
button on the top left of the console.Enable access to unauthenticated identities
under the Unauthenticated Identities
section, click Create pool
button on the bottom right.View Details
section to see the two roles that are to be created. Make a note of the unauth
role whose name is of the form Cognito_<IdentityPoolName>Unauth_Role
. Now click Allow
button in the bottom right of the console.Get AWSCredentials
section, in the code snippet to create CognitoCachingCredentialsProvider
, find the Identity pool ID and the AWS region and make note of them. You will need to add to the sample application later.unauth
role you just created in step 1, which is of the form Cognito_<IdentityPoolName>Unauth_Role
.Attach Policy
, then find AmazonS3FullAccess
and attach it it to the role.Add the following libraries in your app/build.gradle :-
Make sure following permissions are present in your project’s Manifest
file :-
Create a single instance of AmazonS3Client
throughout your application by adding below lines in your Application Class
. You’ll need to pass the IdentityPoolId
that we created above.
Well there you go, now you know how to setup a S3 bucket, configure the AWS SDK for android and upload an image.
If you have any questions or suggestions, please post them below. I would be more than happy to receive feedback from the community.