In addition to condictions for bucket, key, and acl, the policy document must contain rules for name, Filename, and success_action_status. For instance:
Filename is a field that the Flash backend sends, but the HTML5 backend does not.
The multipart setting must be True, but that is the default these days.
The multipart_params setting must be a dictionary with the following fields:
key
AWSAccessKeyId
acl = 'private'
policy
signature
success_action_status = '201'
Setting success_action_status to 201 causes S3 to return an XML document with HTTP status code 201. This is necessary to make the flash backend work. (The flash upload stalls when the response is empty and the code is 200 or 204. It results in an I/O error if the response is a redirect.)
S3 does not understand chunks, so remove the chunk_size config option.
unique_names can be either True or False, both work.
Latest Plupload release has illustrative example included, that shows nicely how one might use Plupload to upload files to Amazon S3, using Flash and SilverLight runtimes.
I want to notice, that don't forget to upload crossdomain.xml to your s3 host, and also if you have success_action_redirect url, you need to have crossdomain.xml file on that domain too. I spent 1 day fighting with that problem, and finally found what's wrong. So next time think how flash work inside.
发布评论
评论(5)
除了存储桶、密钥和 acl 的条件外,策略文档还必须包含名称、文件名和 success_action_status 的规则。例如:
Filename
是Flash后端发送的字段,但HTML5后端不会发送。multipart
设置必须为 True,但这是目前的默认设置。multipart_params
设置必须是包含以下字段的字典:键
AWSAccessKeyId
acl = '私有'
政策
签名
success_action_status = '201'
将
success_action_status
设置为 201 会导致 S3 返回带有 HTTP 状态代码 201 的 XML 文档。这是使 Flash 后端正常工作所必需的。 (当响应为空且代码为 200 或 204 时,Flash 上传会停止。如果响应是重定向,则会导致 I/O 错误。)S3 不理解块,因此请删除
chunk_size
配置选项。unique_names
可以是 True 或 False,两者都有效。In addition to condictions for bucket, key, and acl, the policy document must contain rules for name, Filename, and success_action_status. For instance:
Filename
is a field that the Flash backend sends, but the HTML5 backend does not.The
multipart
setting must be True, but that is the default these days.The
multipart_params
setting must be a dictionary with the following fields:key
AWSAccessKeyId
acl = 'private'
policy
signature
success_action_status = '201'
Setting
success_action_status
to 201 causes S3 to return an XML document with HTTP status code 201. This is necessary to make the flash backend work. (The flash upload stalls when the response is empty and the code is 200 or 204. It results in an I/O error if the response is a redirect.)S3 does not understand chunks, so remove the
chunk_size
config option.unique_names
can be either True or False, both work.最新的 Plupload 版本包含说明性示例,很好地展示了如何使用 Plupload 通过 Flash 和 SilverLight 运行时将文件上传到 Amazon S3。
以下是最新的文章:上传到 Amazon S3
Latest Plupload release has illustrative example included, that shows nicely how one might use Plupload to upload files to Amazon S3, using Flash and SilverLight runtimes.
Here is the fresh write-up: Upload to Amazon S3
官方 Plupload 教程,比这里的答案更详细:https:// github.com/moxiecode/plupload/wiki/Upload-to-Amazon-S3
The official Plupload tutorial, much more detailed than the answers here: https://github.com/moxiecode/plupload/wiki/Upload-to-Amazon-S3
如果您使用的是 Rails 3,请查看我的示例项目:
使用 Rails 3、Flash 和基于 MooTools 的 FancyUploader 直接上传到 S3 的示例项目:https://github.com/iwasrobbed/Rails3-S3-Uploader-FancyUploader
使用 Rails 3、Flash/Silverlight/GoogleGears/BrowserPlus 和基于 jQuery 的 Plupload 的示例项目直接上传到 S3: https://github.com/iwasrobbed/Rails3-S3-Uploader -Plupload
If you are using Rails 3, please check out my sample projects:
Sample project using Rails 3, Flash and MooTools-based FancyUploader to upload directly to S3: https://github.com/iwasrobbed/Rails3-S3-Uploader-FancyUploader
Sample project using Rails 3, Flash/Silverlight/GoogleGears/BrowserPlus and jQuery-based Plupload to upload directly to S3: https://github.com/iwasrobbed/Rails3-S3-Uploader-Plupload
我想注意的是,不要忘记将 crossdomain.xml 上传到您的 s3 主机,而且如果您有 success_action_redirect url,您也需要在该域上有 crossdomain.xml 文件。我花了1天的时间来解决这个问题,终于找到了问题所在。所以下次想想flash内部是如何工作的。
希望我能为某人节省时间。
I want to notice, that don't forget to upload crossdomain.xml to your s3 host, and also if you have success_action_redirect url, you need to have crossdomain.xml file on that domain too. I spent 1 day fighting with that problem, and finally found what's wrong. So next time think how flash work inside.
Hope I save time for someone.