English 中文(简体)
How do I make Plupload upload directly to Amazon S3?
原标题:

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

最佳回答
  • 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.
问题回答

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

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

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

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.





相关问题
how to debug curl call to amazon s3 when it get stuck

I m using the PHP S3 class and this backup script to backup ~500Mb file from Linux server to S3. The call to s3 gets stuck (never returns) and top shows httpd process which consumes 100% CPU and 1% ...

Synchronizing S3 Folders/Buckets [closed]

I have an S3 Bucket that holds static content for all my clients in production. I also have a staging environment which I use for testing before I deploy to production. I also want the staging ...

Pure Javascript app + Amazon S3?

I m looking to confirm or refute the following: For what I have read so far it is not possible to write a web application with only javascript -- no server side logic -- served from Amazon S3 that ...

Using a CDN like Amazon S3 to control access to media

I want to use Amazon S3/CloudFront to store flash files. These files must be private as they will be accessed by members. This will be done by storing each file with a link to Amazon using a mysql ...

What s a good way to collect logs from Amazon EC2 instances?

My app is hosted on an Amazon EC2 cluster. Each instance writes events to log files. I need to collect (and data mine) over these logs at the end of each day. What s a recommended way to collect these ...

热门标签