问题
I've been using browser based direct POST uploads with Amazon S3 for a while, and just recently wanted to start posting through HTTPS. Normal HTTP posts work just fine. However, when I post the same form to https://s3.amazonaws.com/, I get a "405 Method Not Allowed".
Do browser based direct AWS POST uploads not support HTTPS? If they do, how can I do it without getting a 405 error?
Thanks!
回答1:
It could be some 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 AMAZON S3 documentation link for more detail: http://docs.amazonwebservices.com/AmazonS3/latest/dev/HTTPPOSTForms.html#HTTPPOSTFormDeclaration
There is also a another post on this. Amazon S3 - HTTPS/SSL - Is it possible?
UPDATE: I was able to upload objects to S3 bucket over SSL using this HTML & Policy.Check the form action.
Policy :
{
"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 generate encoded policy and signature.
来源:https://stackoverflow.com/questions/9894994/how-do-you-upload-files-directly-to-s3-over-ssl