Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 2.53 KB

README.rdoc

File metadata and controls

43 lines (32 loc) · 2.53 KB

Uploadify-S3

This rails plugin allows file uploads directly to Amazon S3 (rather than going through your rails app). Useful for large file uploads/video etc. Especially useful if you use Heroku as your deployment platform.

This plugin uses the excellent JQuery based uploadify file uploader. More info at www.uploadify.com/

Rails Installation (see http://github.com/contrast/rails-uploadify-s3 for rails example code)

  1. Install the plugin

<pre>script/plugin install [email protected]:contrast/uploadify-s3.git</pre>

  1. Set your Amazon S3 configuration in ‘config/amazon_s3.xml`

  2. Ensure a crossdomain.xml file is configured in your Amazon S3 bucket

  3. Use the uploadify_s3 helper method in your view

e.g <div id=“VideoGallery” style=“display; none;”></div> <%= uploadify_s3({ :file_input_selector => ‘#file_uploader’, :button_text => ‘Add Video’, :file_ext => ‘*.mov’, :on_success => “ function(f) { $(‘#VideoGallery’).html(‘&lt;video height="250" width="250" src="’ + f.url + ‘" controls="true"&gt;&lt;/video&gt;’); $(‘video-upload’).hide(); }”, :on_error => “function(type, text) { alert(”Problem during file upload type: “ + type + ” text: “ + text); }”}) %>

<input type=“file” name=“uploadify” id=“file_uploader” />

** This simple example will work in safari (i.e .mov files can be displayed directly in safari). This is not a recommended approach for handling cross browser supported video online.

uploadify_s3 tag configuration

  • file_input_selector - The id of the file input

  • button_text - The text for the uploadify button

  • file_ext - The allowed file extensions

  • on_success - A Javascrip callback function on upload complete. A hash of name, size, type and url are passed

  • on_failure - A javascript callback function on upload failure. Error type and text are passed as parameters.

Any comments/patches contributions please contact [email protected]