How do I make Plupload upload directly to Amazon S3?

不打扰是莪最后的温柔 提交于 2019-11-26 19:25:01

问题


How do I configure Plupload properly so that it will upload files directly to Amazon S3?


回答1:


  • In addition to condictions for bucket, key, and acl, the policy document must contain rules for name, Filename, and success_action_status. For instance:

        ["starts-with", "$name", ""],
        ["starts-with", "$Filename", ""],
        ["starts-with", "$success_action_status", ""],
    

    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.



回答2:


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




回答3:


The official Plupload tutorial, much more detailed than the answers here: https://github.com/moxiecode/plupload/wiki/Upload-to-Amazon-S3




回答4:


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




回答5:


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.



来源:https://stackoverflow.com/questions/4639471/how-do-i-make-plupload-upload-directly-to-amazon-s3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!