post - 如何通过 SSL 将文件直接上传到 S3?

标签 post ssl amazon-s3 amazon-web-services

我使用基于浏览器的直接 POST 上传和 Amazon S3 有一段时间了,最​​近我想开始通过 HTTPS 发布。正常的 HTTP 帖子工作得很好。但是,当我将相同的表格发布到 https://s3.amazonaws.com/ 时,我收到“不允许使用 405 方法”。

基于浏览器的直接 AWS POST 上传是否不支持 HTTPS?如果他们这样做,我怎样才能在不收到 405 错误的情况下做到这一点?

谢谢!

最佳答案

这可能是您的 HTML FORM 操作有问题。

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/".

请查看此 AMAZON S3 文档链接以获取更多详细信息: http://docs.amazonwebservices.com/AmazonS3/latest/dev/HTTPPOSTForms.html#HTTPPOSTFormDeclaration

关于此还有另一篇文章。 Amazon S3 - HTTPS/SSL - Is it possible?

更新: 我能够使用此 HTML 和策略通过 SSL 将对象上传到 S3 存储桶。检查表单操作。

政策:

{
  "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>

您必须知道如何生成编码策略和签名。

关于post - 如何通过 SSL 将文件直接上传到 S3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9894994/

相关文章:

java - ResourceNameDiscover Class Not Found Axis 1.4 中的异常

python - 使用 boto3、Python 从 S3 存储桶查找最新的 CSV 文件

amazon-web-services - 是否可以使用 POST 直接从 URL 上传到 S3?

PHP:由于身份验证服务器,POST 数据丢失

python - 安装 spaCy - SSL 证书错误

java - 使用 JSP 获取通过 POST 选择哪个单选按钮

ssl - 阅读我的计算机在 ssl 连接上发送的信息

ruby-on-rails - 雾 OpenSSL 错误

发送到 http post 和设置实体时 IOS Json 错误

python Mechanize 代码以获取网页截图 - 但表单提交不工作