Skip to content

travisp/Paperclip-Cloudfiles-Storage-Extension

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Paperclip::Storage::Cloudfiles extension
===============
This is an extension to the popular paperclip plugin, Cloudfiles fork
This is NOT the paperclip plugin itself. It needs the paperclip plugin to be installed in your vendor/plugins directory

For information on the paperclip plugin itself, see the excellent tutorial on http://github.com/thoughtbot/paperclip
For information on the cloudfiles fork of the paperclip plugin, see: https://github.com/minter/paperclip

Remade for Cloudfiles, based off of finknottle's Paperclip-Storage-Extension: https://github.com/finknottle/Paperclip-Storage-Extension

What this extension does
========================
The paperclip plugin is great to add files to your existing model without requiring an additional model.
A forked version of papercli[ has a module called Cloudfiles which allows you to store your uploaded files in your Cloudfiles account. The buckets can be defined in the configuration YAML file, typically called #{RAILS_ROOT}/config/rackspace_cloudfiles.yml.
The configuration file looks like

	development: 
	  username: yourusernamehere
	  api_key: yourapikeyhere
	  container: dev_avatars

	production:
	  username: yourusernamehere
	  api_key: yourapikeyhere
	  container: avatars

The problem though is that when you are developing on your machine, or creating a test machine, but with the production environment, then you want to copy the db from your production machine, and play with the data. At this point, you usually want your files (typically images) to be available for your environment. But at the same time, you don't want to change the files in your production bucket when you change them in your development or test environment.

This is where this extension comes in. The extension allows you to add two more configuration options to your YAML file. So that, the file then looks like 

	development:
	  username: yourusernamehere
	  api_key: yourapikeyhere
	  container: dev_avatars
	  container_alt: avatars
	  testing: true

	production:
	  username: yourusernamehere
	  api_key: yourapikeyhere
	  container: avatars
	  testing: false

You can add the additional two options through a capistrano recipe or a chef recipe, based on your deployment mechanism.
Thus, in your production environment, everything will work as before, all reads and writes will occur on the production bucket defined in the configuration bucket:

However, in an environment with testing set to true, the reads will be done from your container if it exists, but will check your production bucket if it does not. The writes and deletes will still be done from your bucket.


Installation
============
Simply add this file to the #{RAILS_ROOT}/lib/ directory, and call it in the environment.rb file below the Rails Initializer block
	require 'lib/paperclip_storage_ext'
	

About

Paperclip::Storage::S3 Extension for development/testing purposes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%