How do you upload files directly to S3 via SSL?

I have been using direct browser-based POST downloads with Amazon S3 for a while, and most recently I wanted to start publishing via HTTPS. Regular HTTP messages work fine. However, when I submit the same form to https://s3.amazonaws.com/ , I get a "405 method not allowed".

Does the browser support direct downloads of POST POST HTTPS? If they do, how can I do this without getting a 405 error?

Thanks!

+4
source share
1 answer

This may be a problem with your HTML FORM action.

The action specifies the URL that processes the request, which must be set to the URL of the bucket. For example, if the name of your bucket is "johnsmith", the URL is "http://johnsmith.s3.amazonaws.com/". 

Please check this documentation for AMAZON S3 documentation for more details: http://docs.amazonwebservices.com/AmazonS3/latest/dev/HTTPPOSTForms.html#HTTPPOSTFormDeclaration

There is another article on this. Amazon S3 - HTTPS / SSL - Is it Possible?

UPDATE: I was able to upload objects to the SSL bucket over SSL using this HTML and policy. Check the action of the form.

Politics:

 { "expiration": "2012-06-04T12:00:00.000Z", "conditions": [ {"bucket": "<YourBucketName>" }, {"acl": "public-read" }, ["eq", "$key", "testImage.jpg"], ["starts-with", "$Content-Type", "image/jpeg"], ] } 

HTML:

 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <form action="https://s3.amazonaws.com/<YourBucketName>/" method="post" enctype="multipart/form-data"> <input type="text" name="key" value="testImage.jpg" /> <input type="text" name="acl" value="public-read" /> <input type="text" name="content-type" value="image/jpeg" /> <input type="hidden" name="AWSAccessKeyId" value="<YOUR ACCESS KEY>" /> <input type="hidden" name="policy" value="<YOUR GENERATED POLICY>" /> <input type="hidden" name="signature" value="<YOUR GENERATED SIGNATURE>" /> <input name="file" type="file" /> <input name="submit" value="Upload" type="submit" /> </form> </body> </html> 

You must know how to create a coded policy and signature.

+7
source

Source: https://habr.com/ru/post/1403721/


All Articles