/paperclip_on_akamai

Enables Paperclip Plugin to use Akamai for Asset Storage

Primary LanguageRubyMIT LicenseMIT

PaperclipOnAkamai
=================

A simple addition to Paperclip. I doesn't uses Akamai as only Storage but rather saves all files local and pushs copies to Akamai. Best way to use is with delayed_job since Uploading to Akamai via SCP takes some time.

The Plugin adds a 8 digit random hex string to all filenames. This helps with Akamai Caching, every new version of the same file (if it has the same filename at all) gets a new filename on akamai, every old version is deleted. Between modifying the attachment and uploading to akamai, local urls are generated for that attachment.

Installation
============

  ruby script/plugin install git://github.com/Soph/paperclip_on_akamai.git


Basic Usage
===========

  1. ruby script/generate paperclip_on_akamai Class <attachment>
  
  2. run rake db:migrate
  
  3. change "has_attached_file" to "has_attached_file_on_akamai"
  
  4. copy example_akamai.yml to RAILS_ROOT/config/akamai.yml and edit all values (delayed_job is recommended)
    
Example
=======

  Console: 
  
  ruby script/generate paperclip_on_akamai Teaser image
  
  
  Teaser.rb: 
  
  has_attached_file_on_akamai :image,
    :path   => ':rails_root/public/assets/teasers/:id_partition/:style/:basename.:extension',
    :url    => '/assets/teasers/:id_partition/:style/:basename.:extension',
    :styles => { :main_full  => ['566x318#'] }
    
TODO / Known Problems
=====================

* after_destroy hook for removing unneeded files from akamai
* specs 
    
Copyright (c) 2009 Stefan Haubold, released under the MIT license