Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure aws s3 bucket to accept signed urls on Heroku?

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

like image 847
Tormod Smith Avatar asked Apr 14 '16 21:04

Tormod Smith


People also ask

Why is S3 object URL Access Denied?

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.

What is the valid URL for Amazon S3 bucket access?

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/


1 Answers

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.

like image 91
Mattias Andersson Avatar answered Nov 15 '22 05:11

Mattias Andersson