Rails S3 Flash upload plugin

S3 flash upload is a rails plugin which allow user uploading a file to your S3 bucket directly, so you can save the cost of forwarding file to S3 in your app side.

Install

$ script/plugin install git://github.com/elcgit/s3-swf-upload-plugin.git

Usage

1. To use it, you should first execute the generator.

$ script/generate s3_swf_upload

2. configure config/amazon_s3.yml, you need put a crossdomain.xml in your bucket and make it public-read.

3. include s3_upload.js in your layouts:

< %= javascript_include_tag 's3_upload' %>

4. init s3_swf object:

Please Update your Flash Player to Flash v9.0.1 or higher...

< %= link_to_function 'Upload', 's3_swf.upload("prefix/")' %>

5. when you click upload, your file will be upload to http://bucket.s3.amazonasw.com/prefix/

This plugin has a new version available here: http://www.elctech.com/articles/updates-on-rails-s3-flash-upload-plugin

4 Comments

  1. charles
    Posted December 29, 2008 at 6:01 pm | Permalink

    Is this easily modified to upload to private bucket?

  2. Posted December 30, 2008 at 4:43 pm | Permalink

    All buckets and objects on S3 are individually access controlled, so you can upload anything anywhere (that you own…) and you just change the access to only be readable by the owner of the file only which would make it private. The way that the S3 POSTs work is that you generate a “policy file” which is basically just a config file of where you want the file uploaded to, what access it has, etc and then you encrypt it using your AWS secret key as a private key. Let me know if you need any help with it :-)

  3. Posted February 26, 2009 at 4:17 am | Permalink

    Hi there,
    Just a question about
    < %= link_to_function 'Upload', 's3_swf.upload("prefix/")' %>

    Is there any server side verification of the upload prefix? Or can someone modify this client side to upload anywhere?

  4. Posted February 27, 2009 at 3:45 am | Permalink

    Hi, Eaden, I think it will upload to anywhere specified in client side at currently. Because file is uploaded to S3 directly, so we can’t verify it on server side.

    we’ll think adding the prefix restriction in next version, thanks for your feedback.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">