Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload from browser directly to S3 (Amazon) and https trouble

I have created a page from where users can upload their files. This code snippet send those files to my Amazon S3 bucket.

<form action="https://BUCKET.s3-eu-west-1.amazonaws.com/" method="post" enctype="multipart/form-data">
  <input type="hidden" name="awsAccessKey" value="ACCESS_KEY">
  <input type="hidden" name="awsSecretKey" value="SECRET_KEY"> 
  <input type="hidden" name="acl" value="private"> 
  <input type="hidden" name="policy" value="POLICY">
  <input type="hidden" name="signature" value="SIGNATURE">
  <input type="hidden" name="Content-Type" value="">
  <!-- Include any additional input fields here -->

  File to upload to S3: 
  <input name="file" type="file"> 
  <br> 
  <input type="submit" value="Upload File to S3"> 
</form> 

Everything works fine, but I am facing https problems. Main browsers don't trust s3-eu-west-1.amazonaws.com and show security message about untrusted connection.

I changed my the HTTPS connection to HTTP so that my customers don't face any problem. Does someone have any ideas on how to resolve this issue?


1 Answers

Chances are your bucket name has a dot in it. Amazon's S3 wildcard certificates are good for only one level of subdomains, so bucket.s3-eu-west-1.amazonaws.com is fine but bucket.bucket.s3-eu-west-1.amazonaws.com is not. Use this instead:

https://s3-eu-west-1.amazonaws.com/BUCKET/
like image 105
ceejayoz Avatar answered Aug 15 '26 14:08

ceejayoz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!