Skip to content

Commit 87b403f

Browse files
authored
Update README for s3 upload example (#504)
1 parent f0aaca7 commit 87b403f

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

solutions/aws-s3-image-upload/README.md

+31-7
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,37 @@ Retrieve your existing access key, secret key, S3 bucket region and name. Provid
3232
3. Enter your default region.
3333
1. Create an `.env.local` file similar to `.env.example`.
3434
1. Enter your access key and secret key from the IAM user.
35-
1. Run `cdk bootstrap`.
36-
1. Run `cdk deploy` to create an S3 bucket with an IAM policy.
37-
1. Visit your newly created S3 bucket and retrieve the name and region.
38-
1. Add the name and region to `.env.local`.
39-
1. Run `yarn dev` to start the Next.js app at `localhost:3000`.
40-
1. Choose a `.png` or `.jpg` file.
41-
1. You should see your file successfully uploaded to S3.
35+
1. You must configure cors, for the upload to work
36+
1. [S3 Documentation](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/s3-example-photo-album.html)
37+
```json
38+
{
39+
"Version": "2012-10-17",
40+
"Statement": [
41+
{
42+
"Effect": "Allow",
43+
"Action": [
44+
"s3:DeleteObject",
45+
"s3:GetObject",
46+
"s3:ListBucket",
47+
"s3:PutObject",
48+
"s3:PutObjectAcl"
49+
],
50+
"Resource": [
51+
"arn:aws:s3:::BUCKET_NAME",
52+
"arn:aws:s3:::BUCKET_NAME/*"
53+
]
54+
}
55+
]
56+
}
57+
```
58+
59+
3. Run `cdk bootstrap`.
60+
4. Run `cdk deploy` to create an S3 bucket with an IAM policy.
61+
5. Visit your newly created S3 bucket and retrieve the name and region.
62+
6. Add the name and region to `.env.local`.
63+
7. Run `yarn dev` to start the Next.js app at `localhost:3000`.
64+
8. Choose a `.png` or `.jpg` file.
65+
9. You should see your file successfully uploaded to S3.
4266

4367
This example uses [`createPresignedPost`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#createPresignedPost-property) instead of [`getSignedUrlPromise`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getSignedUrlPromise-property) to allow setting max/min file sizes with `content-length-range`.
4468

0 commit comments

Comments
 (0)