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

- 17,438
- 13
- 70
- 88
-
4Whilst this question has been answered, my first concern was that by putting all your S3 details on the client, surely a user with bad intentions could take advantage of that information. Hence, thinking others may have the same concern, here is an article which aims to tackle those questions: http://codeonaboat.wordpress.com/2011/04/22/uploading-a-file-to-amazon-s3-using-an-asp-net-mvc-application-directly-from-the-users-browser/ – dazbradbury Mar 06 '12 at 13:42
5 Answers
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.

- 46,496
- 21
- 150
- 195

- 17,438
- 13
- 70
- 88
-
1Direct upload to s3 with the html5 runtime doesn't work at this point. Amazon doesn't currently allow cross-domain requests. – Bastien Mar 15 '11 at 08:23
-
3@Bastien: It works fine to host an HTML page with Plupload on S3, then include it in your main page as an iframe. Use the proxy trick to resize the iframe as necessary. – Vebjorn Ljosa Mar 15 '11 at 13:08
-
2As an aside, I have since started using the service http://transloadit.com/ to process uploads to S3, mostly because they take care of rescaling the images, but also because their setup is more stable than then Plupload-in-iframe solution I concocted. – Vebjorn Ljosa Jul 08 '11 at 13:15
-
Vebjorn: I believe you are mistaken and your comment about HTML5 uploader working is incorrect and has caused a bit of confusion elsewhere. **Only** HTML4 uploading works via the iframe approach. HTML5 will not work. More info here: http://www.plupload.com/punbb/viewtopic.php?pid=2361#p2361 – iwasrobbed Dec 11 '11 at 20:19
-
@iWasRobbed: I am confident that it was not using the HTML4 runtime, as selecting multiple files worked and there was a functional progress bar. It is, however, possible that is was using the flash runtime, and that I was wrong about it working on S3 with HTML5. I cannot easily test it anymore. – Vebjorn Ljosa Dec 12 '11 at 19:13
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

- 16,124
- 24
- 94
- 138
-
1Sounds nice, I didn't find it, I only see the general examples, could you please provide a link – Amala Apr 26 '11 at 18:42
-
-
6A link for everyone else: https://github.com/moxiecode/plupload/blob/master/examples/jquery/s3.php – iwasrobbed May 26 '11 at 12:37
The official Plupload tutorial, much more detailed than the answers here: https://github.com/moxiecode/plupload/wiki/Upload-to-Amazon-S3

- 9,379
- 4
- 40
- 52
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

- 46,496
- 21
- 150
- 195
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.

- 3,283
- 1
- 38
- 44