a simple rails plugin for upload_nginx module and amazon s3 service, inspired in attachment_fu, (work in progress but in production in artenlinea.com)
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
tasks
test
MIT-LICENSE
README
Rakefile
init.rb
install.rb
uninstall.rb

README

ActsAsUploadable
================

Introduction goes here.
is a extremely light uploader for rails, it provides funcionality to upload a file , procesing with image science, and store in s3, this plugin is inspired by attachment_fu plugin.

this plugin works with in conjunction with nginx_upload module

gem requires

the amazon s3 gem is required and  "image_science" too

this plugin works with in conjunction with nginx_upload module,
http://www.grid.net.ru/nginx/upload.en.html, thanks Valery Kholodkov !

starling and simplified_starling plugin

the model required fields are

create_table "art_works", :force => true do |t|
 t.string   "image",          :limit => 200,      :default => "",    :null => false
 t.boolean  "in_s3"
 t.string   "old_filename"
end

Example
=======

to use this , in your model do :


class Photo < ActiveRecord::Base

acts_as_uploadable  :content_type => ['application/pdf','image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg'],    :s3_bucket => 'artenlinea' , :path=>"art_works" ,
:thumbnails => {:options=>[
  {:type=>'resize_to_width',:size=>550,:name=>'resize'},
  {:type=>'cropped_thumbnail',:size=>100,:name=>'thumb'}
  ]}
....
....
end

if you dont need to check for the file in creation include this attribute option  

:file_needed_on_create=>0,
  



/**********************************************************************/
i added in_s3 field to check if the file is in filesystem or in s3 .
when you update a image the old file name keeps in old_filename and the new one is in image field, the old one y deleted from s3 in a starling process.

when you create a image , first it copies to file system, and, in background, it sends to starling the s3 upload to make the upload process faster , 

when the file is on s3 the local copies are deleted, this happens in update and create methods

if the file is in local file system, the view helper links to local file , otherwise it look for s3 file when in_s3 == true

Todo:

a template for a form and a js upload_progress bar (css , js)

create a method to check if there is a s3 connection in the case the s3 service is down,


Copyright (c) 2008 [Miguel Michelson Martinez], released under the MIT license