Permalink
Browse files

Pre release version

  • Loading branch information...
0 parents commit 49226fac832abeca6b1cec1bd2f4c9452fa27f97 @nhocki committed Jun 9, 2011
Showing with 77 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +4 −0 Gemfile
  3. +15 −0 README.textile
  4. +1 −0 Rakefile
  5. +25 −0 lib/paperclip-s3.rb
  6. +5 −0 lib/paperclip-s3/version.rb
  7. +23 −0 paperclip-s3.gemspec
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in paperclip-s3.gemspec
+gemspec
@@ -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.
@@ -0,0 +1 @@
+require 'bundler/gem_tasks'
@@ -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
@@ -0,0 +1,5 @@
+module Paperclip
+ module S3
+ VERSION = "1.0.0pre"
+ end
+end
@@ -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 = ["nhocki@gmail.com"]
+ 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.