Skip to content
This repository has been archived by the owner on Jun 6, 2018. It is now read-only.

Commit

Permalink
Pre release version
Browse files Browse the repository at this point in the history
  • Loading branch information
nhocki committed Jun 9, 2011
0 parents commit 49226fa
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.gem
.bundle
Gemfile.lock
pkg/*
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "http://rubygems.org"

# Specify your gem's dependencies in paperclip-s3.gemspec
gemspec
15 changes: 15 additions & 0 deletions README.textile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
h1. Paperclip S3 Storage

This gem will force paperclip to store attachments on S3. It's great for "Heroku":http://heroku.com apps and thats basically why I wrote it.

I was really lazy writing this over and over again, so I just gemed it.

h1. Important Notes

If you're in fact using "Heroku":http://heroku.com, and you want the attachments to have custom paths. *PLEASE* do not use *RAILS_ROOT*. Why? Every time you deploy your app to "Heroku":http://heroku.com, 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 on by default, so you can just use it.

h2. Contribute

Feel free to fork, fix/patch/extend this. Everything is welcome.
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'bundler/gem_tasks'
25 changes: 25 additions & 0 deletions lib/paperclip-s3.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require "paperclip-s3/version"

module Paperclip
module S3

# Extends the paperclips has_attached_file method
# It will use S3 Storage. The credentials will be read from the environment
def has_attached_file(name, options = {})
options[:storage] ||= :s3
options[:path] ||= "/:class-:attachment/:id/:style-:basename.:extension"
options[:bucket] ||= ENV["S3_BUCKET"]
options[:s3_credentials] ||= {
:access_key_id => ENV['S3_KEY'],
:secret_access_key => ENV['S3_SECRET']
}
super(name, options)
end


end
end

if defined?(ActiveRecord) and defined?(Rails)
ActiveRecord::Base.send :extend, Paperclip::S3 if Rails.env.production?
end
5 changes: 5 additions & 0 deletions lib/paperclip-s3/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Paperclip
module S3
VERSION = "1.0.0pre"
end
end
23 changes: 23 additions & 0 deletions paperclip-s3.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "paperclip-s3/version"

Gem::Specification.new do |s|
s.name = "paperclip-s3"
s.version = Paperclip::S3::VERSION
s.authors = ["Nicolás Hock Isaza"]
s.email = ["[email protected]"]
s.homepage = ""
s.summary = %q{Simple gem that makes paperclip save the attachments on Amazon S3 for a production Rails application.}
s.description = %q{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.}

s.rubyforge_project = "paperclip-s3"

s.add_dependency('paperclip', '~> 2.3.11')
s.add_dependency('aws-s3', '~> 0.6.2')

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
end

0 comments on commit 49226fa

Please sign in to comment.