This will be built off of the tutorial for viewing photos. While not a prequisite, my original attempt to use the upload photo tutorial failed, so this attempt will try to remedy that by building off of a successful implementation.
A working version of the demo can be found here.
- The tutorial for viewing photo albums can be found here
- The tutorial for uploading files can be found here
- This is the information regarded to the amazon resources used. Note that if you want to implement this tutorial yourself, the bucket's name, the policy name, the pool name, the unauthorized role, and the pools identity will all be whatever you name those entities in your AWS console.
- S3 Bucket
- bucket name: viewphotobucket
- Updated CORS Configuration:
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <CORSRule> <AllowedOrigin>*</AllowedOrigin> <AllowedMethod>POST</AllowedMethod> <AllowedMethod>GET</AllowedMethod> <AllowedMethod>PUT</AllowedMethod> <AllowedMethod>DELETE</AllowedMethod> <AllowedMethod>HEAD</AllowedMethod> <AllowedHeader>*</AllowedHeader> <ExposeHeader>ETag</ExposeHeader> </CORSRule> </CORSConfiguration>
- IAM
- new policy name: UploadBucketPolicy
- allows s3:DeleteObject, GetObject, ListBucket, and Put object on our bucket
- new policy name: UploadBucketPolicy
- Cognito Identity Pool
- pool name: ViewPhotoIdentity
- Unauthorized Role: Cognito_ViewPhotoIdentityUnauth_Role
- sample code:
AWS.config.region = 'us-east-1'; // Region AWS.config.credentials = new AWS.CognitoIdentityCredentials({ IdentityPoolId: 'us-east-1:7bbbddf8-b270-4cf2-af9b-c8a4bd406f12', });
- polly.html was implemented just to test that the Cognito Identity Pool functioned properly
- S3 Bucket