Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created June 2, 2011 18:52
Show Gist options
  • Save brandon-beacher/1005027 to your computer and use it in GitHub Desktop.
Save brandon-beacher/1005027 to your computer and use it in GitHub Desktop.

Pros

Uses a separate Uploader class which can share behavior with more than one model

https://gist.github.com/1005026

Uploaders can use the Fog cloud abstraction library

http://fog.io

  • Amazon S3
  • Rackspace CloudFiles
  • Google Storage for Developers
  • Local Storage

https://gist.github.com/1005017

Uploaders are designed well for easy customization

https://github.com/highgroove/discovery-port/blob/master/app/uploaders/attachment_uploader.rb#L13-19

Local Storage can be used in development to avoid the overhead of the wire

https://github.com/highgroove/discovery-port/blob/master/config/initializers/carrierwave.rb#L3

Processing can be disabled in test to avoid the overhead of processing (resizing, etc.)

https://github.com/highgroove/discovery-port/blob/master/config/initializers/carrierwave.rb#L7-8

Cons

Does some kind of tricky black magic on the ActiveRecord field

https://gist.github.com/1005011

Workaround - just store it at the moment we get it from the browser

add_column :attachments, :original_filename,  :string
add_column :attachments, :content_type,       :string

https://github.com/highgroove/discovery-port/blob/master/app/controllers/attachments_controller.rb#L9-12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment