-
Notifications
You must be signed in to change notification settings - Fork 53
S3 in Development
If you would like to store your user-uploaded files on S3 in development, you will first need to set up an AWS account and create an S3 bucket for your app. This needs to be a unique name in the AWS global namespace.
You will then need to create a .env
file in the root of your application directory with the following:
AWS_ACCESS_KEY_ID=XXX
AWS_SECRET_ACCESS_KEY=YYY
AWS_BUCKET=bucket-name
If you would like to use the direct-to-S3 uploader in development, you will additionally need to edit the CORS configuration for your bucket to allow uploads from your dev environment. Go to the S3 interface, click on your bucket and then select the Properties
button. Click on the Edit CORS configuration
button and add the following:
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>http://localhost:3000</AllowedOrigin>
<AllowedMethod>POST</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
If you already have a CORSConfiguration
section, just put the CORSRule
section inside. AllowedOrigin
should be whatever URL you use to access your local dev environment.
Once you have this in place, the direct uploader functionality should work properly.