Permalink
Browse files

License & readme words

  • Loading branch information...
1 parent 07794a1 commit 1d8cbc1479c46741d0e9482ff148764488fd55b8 @nhocki committed Feb 1, 2013
Showing with 46 additions and 12 deletions.
  1. +22 −0 LICENSE.txt
  2. +19 −7 README.textile
  3. +5 −5 lib/paperclip-s3.rb
View
@@ -0,0 +1,22 @@
+Copyright (c) 2013 Nicolás Hock Isaza
+
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,18 +1,27 @@
h2. Paperclip S3 Storage
-This gem will force paperclip to store attachments on S3 if your application is in production. It's great for "Heroku":http://heroku.com apps.
+This gem will force paperclip to store attachments on S3 if your application is
+in production. It's great for "Heroku":http://heroku.com apps.
h2. 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!
+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.
+A default, Heroku-working path is default.
h2. How to Use
-Add the gem to your Gemfile with <pre>gem "paperclip-s3"</pre> and run <pre>bundle install</pre>.
+Add the gem to your Gemfile with <pre>gem "paperclip-s3"</pre> and run
+<pre>bundle install</pre>.
-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.)
+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":http://heroku.com, you can use the <pre>config:add</pre> command:
@@ -30,13 +39,16 @@ If you are using *https* as the S3 Protocol, you can also specify it as a Heroku
<b>Notice that the S3 protocol will default to http</b>
-You can optionally specify which environments will use S3 with the S3_ENVIRONMENTS variable (using a comma-separated list).
+You can optionally specify which environments will use S3 with the
+<pre>S3_ENVIRONMENTS</pre> variable (using a comma-separated list).
<pre>
ENV['S3_ENVIRONMENTS'] = 'staging,production' # defaults to production only
</pre>
-*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.)
+*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.)
<pre>
class User < ActiveRecord::Base
View
@@ -5,14 +5,14 @@
module Paperclip
module S3
-
+
# Use Paperclip::S3::Glue to keep the original gem style
module Glue
def self.included base
base.extend ClassMethods
end
end
-
+
module ClassMethods
# Extends the paperclips has_attached_file method
# It will use S3 Storage. The credentials will be read from the environment
@@ -23,9 +23,9 @@ def has_attached_file(name, options = {})
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']
- }
+ :access_key_id => ENV['S3_KEY'],
+ :secret_access_key => ENV['S3_SECRET']
+ }
super(name, options)
end
end

0 comments on commit 1d8cbc1

Please sign in to comment.