paperclip-s3 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +21 -7
- data/lib/paperclip-s3/railtie.rb +3 -3
- data/lib/paperclip-s3/version.rb +1 -1
- metadata +11 -11
data/README.textile
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
-
|
1
|
+
h2. Paperclip S3 Storage
|
2
2
|
|
3
3
|
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.
|
4
4
|
|
5
|
-
|
5
|
+
h2. Important Notes
|
6
6
|
|
7
7
|
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!
|
8
8
|
|
9
9
|
A default, Heroku-working path is on by default, so you can just use it.
|
10
10
|
|
11
|
-
|
11
|
+
h2. How to Use
|
12
12
|
|
13
|
-
|
13
|
+
Add the gem to your Gemfile with <pre>gem "paperclip-s3"</pre> and run <pre>bundle install</pre>.
|
14
14
|
|
15
|
-
|
15
|
+
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.)
|
16
|
+
|
17
|
+
If you are using "Heroku":http://heroku.com, you can use the <pre>config:add</pre> command:
|
16
18
|
|
17
19
|
<pre>
|
18
20
|
heroku config:add S3_BUCKET=your_bucket_name
|
@@ -26,9 +28,21 @@ If you are using *https* as the S3 Protocol, you can also specify it as a Heroku
|
|
26
28
|
heroku config:add S3_PROTOCOL=https
|
27
29
|
</pre>
|
28
30
|
|
29
|
-
|
31
|
+
<b>Notice that the S3 protocol will default to http</b>
|
32
|
+
|
33
|
+
You can optionally specify which environments will use S3 with the S3_ENVIRONMENTS variable (using a comma-separated list).
|
34
|
+
|
35
|
+
<pre>
|
36
|
+
ENV['S3_ENVIRONMENTS'] = 'staging,production' # defaults to production only
|
37
|
+
</pre>
|
38
|
+
|
39
|
+
*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.)
|
30
40
|
|
31
|
-
|
41
|
+
<pre>
|
42
|
+
class User < ActiveRecord::Base
|
43
|
+
has_attached_file :avatar, default_url: "/images/defaults/photo-missing.jpg"
|
44
|
+
end
|
45
|
+
</pre>
|
32
46
|
|
33
47
|
h2. Contribute
|
34
48
|
|
data/lib/paperclip-s3/railtie.rb
CHANGED
@@ -14,11 +14,11 @@ module Paperclip
|
|
14
14
|
class Railtie
|
15
15
|
def self.insert
|
16
16
|
in_production = false
|
17
|
-
|
17
|
+
s3_environments = ENV['S3_ENVIRONMENTS'] ? ENV['S3_ENVIRONMENTS'].split(',') : ['production']
|
18
18
|
if (defined?(Rails.env) && Rails.env)
|
19
|
-
in_production = Rails.env
|
19
|
+
in_production = s3_environments.include?(Rails.env)
|
20
20
|
elsif (defined?(RAILS_ENV) && RAILS_ENV)
|
21
|
-
in_production = RAILS_ENV
|
21
|
+
in_production = s3_environments.grep(RAILS_ENV)
|
22
22
|
end
|
23
23
|
|
24
24
|
ActiveRecord::Base.send(:include, Paperclip::S3::Glue) if in_production
|
data/lib/paperclip-s3/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: paperclip
|
16
|
-
requirement: &
|
16
|
+
requirement: &70200707906980 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.4'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70200707906980
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: aws-sdk
|
27
|
-
requirement: &
|
27
|
+
requirement: &70200707905600 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.2.5
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70200707905600
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70200707904840 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 0.9.2
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70200707904840
|
47
47
|
description: The gem will simply extend the has_attached_file to make it store on
|
48
48
|
Amazon S3 when the application is on production. Great for Heroku applications.
|
49
49
|
email:
|
@@ -76,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
segments:
|
78
78
|
- 0
|
79
|
-
hash:
|
79
|
+
hash: 2328084954864956587
|
80
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
@@ -85,10 +85,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
segments:
|
87
87
|
- 0
|
88
|
-
hash:
|
88
|
+
hash: 2328084954864956587
|
89
89
|
requirements: []
|
90
90
|
rubyforge_project: paperclip-s3
|
91
|
-
rubygems_version: 1.8.
|
91
|
+
rubygems_version: 1.8.17
|
92
92
|
signing_key:
|
93
93
|
specification_version: 3
|
94
94
|
summary: Simple gem that makes paperclip save the attachments on Amazon S3 for a production
|