This repository has been archived by the owner on Jun 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 49226fa
Showing
7 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.gem | ||
.bundle | ||
Gemfile.lock | ||
pkg/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'bundler/gem_tasks' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Paperclip | ||
module S3 | ||
VERSION = "1.0.0pre" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |