如何通过SSL将文件直接上传到S3? [英] How do you upload files directly to S3 over SSL?

查看:55
本文介绍了如何通过SSL将文件直接上传到S3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我一直在与Amazon S3一起使用基于浏览器的直接POST上传,最近才想开始通过HTTPS进行发布.正常的HTTP发布工作正常.但是,当我将相同的表单发布到 https://s3.amazonaws.com/时,我会收到一个"405方法不允许".

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

基于浏览器的直接AWS POST上传是否不支持HTTPS?如果他们这样做了,怎么办却又不会出现405错误?

Do browser based direct AWS POST uploads not support HTTPS? If they do, how can I do it without getting a 405 error?

谢谢!

推荐答案

您的HTML FORM操作可能有问题.

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

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

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

对此还有另一篇文章. Amazon S3-HTTPS/SSL-有可能吗?

There is also a another post on this. Amazon S3 - HTTPS/SSL - Is it possible?

更新:我可以使用此HTML&通过SSL将对象上传到S3存储桶.政策.检查表单操作.

UPDATE: I was able to upload objects to S3 bucket over SSL using this HTML & Policy.Check the form action.

政策:

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

这篇关于如何通过SSL将文件直接上传到S3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆