Permalink
Browse files

Adding S3_PROTOCOL option

Fix #4
  • Loading branch information...
1 parent 5a7895b commit 1cce679b9e2855b624fecd05f6e1bd3f892d578e @nhocki committed Dec 22, 2011
Showing with 7 additions and 9 deletions.
  1. +4 −8 README.textile
  2. +3 −1 lib/paperclip-s3.rb
View
12 README.textile
@@ -20,20 +20,16 @@ If you are using "Heroku":http://heroku.com, it's really easy to do this, just
heroku config:add S3_SECRET=your_secret_key
</pre>
-Ok, if you're really lazy, you can do that in one line:
+If you are using *https* as the S3 Protocol, you can also specify it as a Heroku environment variable.
<pre>
- heroku config:add S3_BUCKET=your_bucket_name S3_KEY=your_access_key S3_SECRET=your_secret_key
+ heroku config:add S3_PROTOCOL=https
</pre>
-After you've done this, you can use paperclip normally. The gem just extends this methods and changes the options to force the S3 Storage. You can *even* use the same options (like path, default_style, etc.)
-
+`Notice that the S3 protocol will default to *http*`
+After you've done this, you can use paperclip normally. The gem just extends this methods and changes the options to force the S3 Storage. You can *even* use the same options (like path, default_style, etc.)
h2. Contribute
Feel free to fork, fix/patch/extend this. Everything is welcome.
-
-h3. TODO
-
-* Clean the Railtie, specially the Rails.env part.
View
4 lib/paperclip-s3.rb
@@ -6,7 +6,7 @@
module Paperclip
module S3
- # Use Paperclip::S3::Glue to keep the original gems style
+ # Use Paperclip::S3::Glue to keep the original gem style
module Glue
def self.included base
base.extend ClassMethods
@@ -17,9 +17,11 @@ module ClassMethods
# 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 = {})
+ s3_protocol = !!ENV["S3_PROTOCOL"] ? ENV["S3_PROTOCOL"] : "http"
options[:storage] = :s3
options[:path] ||= "/:class-:attachment/:id/:style-:basename.:extension"
options[:bucket] ||= ENV["S3_BUCKET"]
+ options[:s3_protocol] ||= s3_protocol
options[:s3_credentials] ||= {
:access_key_id => ENV['S3_KEY'],
:secret_access_key => ENV['S3_SECRET']

0 comments on commit 1cce679

Please sign in to comment.