I am using Node.js to get a signed url from aws s3 using the putObject from the (aws-sdk) module. When I run my server locally there is no problem with the upload to S3. When I deploy my code to heroku and choose a file to upload I'm getting the following error in my chrome console:
https://torhuw-hrns.s3.amazonaws.com/5f522890-0283-11e6-a696-b1fc6f56c785-T…4&Signature=P7ybw4%2B2qqNRNKTZbc%2FMWLhPn1o%3D&x-amz-acl=public-read-write Failed to load resource: the server responded with a status of 403 (Forbidden)
I am using Node.js (aws-sdk) s3getSignedUrl method to get the signature and sending this to the front end to upload my files to my s3 bucket.
The tutorial I followed is Direct to S3 File Uploads in Node.js
If you're trying to host a static website using Amazon S3, but you're getting an Access Denied error, check the following requirements: Objects in the bucket must be publicly accessible. S3 bucket policy must allow access to the s3:GetObject action. The AWS account that owns the bucket must also own the object.
An S3 bucket can be accessed through its URL. The URL format of a bucket is either of two options: http://s3.amazonaws.com/[bucket_name]/ http://[bucket_name].s3.amazonaws.com/
Double-check your S3 bucket's permissions and CORS configuration. You need to make sure that the policy allows "s3:PutObject" on your bucket and you need to make sure that the CORSRule allows PUT/POST and allows your app's domain.
To debug these things, you may consider temporarily relaxing all the permissions to "wide open" and checking that it works when completely unrestricted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With