0.02
Repository is archived
No commit activity in last 3 years
No release in over 3 years
The gem will simply extend the has_attached_file to make it store on Amazon S3 when the application is on production. Great for Heroku applications.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.9.2

Runtime

~> 1.2.5
~> 2.4
 Project Readme

This is no longer maintained!!


Paperclip S3 Storage

This gem will force paperclip to store attachments on S3 if your application is
in production. It’s great for Heroku apps.

Important Notes

If you’re in fact using Heroku, and you want the
attachments to have custom paths. PLEASE do not use RAILS_ROOT. Why? Every
time you deploy your app to Heroku, you’re changing the
RAILS_ROOT, so all your uploaded files will be lost and your bucket WILL be a mess!

A default, Heroku-working path is default.

How to Use

Add the gem to your Gemfile with

gem “paperclip-s3”
and run
bundle install
.

Then, you’ll need to setup some ENV variables. You will need to provide a secret
key, an access key and a bucket.

You can provide an s3_credentials hash options with access_key_id and
secret_access_key instead.

If you are using Heroku, you can use the

config:add
command:

  heroku config:add S3_BUCKET=your_bucket_name
  heroku config:add S3_KEY=your_access_key
  heroku config:add S3_SECRET=your_secret_key

If you are using https as the S3 Protocol, you can also specify it as a Heroku environment variable.

  heroku config:add S3_PROTOCOL=https

Notice that the S3 protocol will default to http

You can optionally specify which environments will use S3 with the

S3_ENVIRONMENTS
variable (using a comma-separated list).

  ENV['S3_ENVIRONMENTS'] = 'staging,production' # defaults to production only

After you’ve done this, you can use paperclip normally. The gem just extends
the methods and changes the options to force the S3 Storage. You can even use
the same options (like path, default_style, etc.)

  class User < ActiveRecord::Base
    has_attached_file :avatar, default_url: "/images/defaults/photo-missing.jpg"
  end

Contribute

Feel free to fork, fix/patch/extend this. Everything is welcome.