paperclip-aws-core 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paperclip/aws/core/version.rb +1 -1
- data/lib/paperclip/aws/core.rb +16 -15
- data/paperclip-aws-core.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a8121fc4a9d181c3d36d4ea42140543dea072ca
|
4
|
+
data.tar.gz: 647c97fade4b0a2b2db78282bf43428aa373db9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b7754c4b4c90145a702073ab376938a4c2a498790fe0a97c050e533a2b8ad7350493c08b61738732bc372ad9c2f148fe3d6d0873a96562041656b15c42ee8b0
|
7
|
+
data.tar.gz: e9f4d687f3932ccf31c38a92d8012a75e276c046fb926ac10a6ef3733fac7a71a6ebaa66b3917e514d60cb3f0699369070e300ca62b79efe9b3e25a41519ad81
|
data/lib/paperclip/aws/core.rb
CHANGED
@@ -14,15 +14,16 @@ module Paperclip
|
|
14
14
|
|
15
15
|
base.instance_eval do
|
16
16
|
@s3_options = @options[:s3_options] || {}
|
17
|
-
|
18
|
-
@s3_endpoint = @options[:s3_endpoint]
|
19
|
-
|
17
|
+
|
18
|
+
@s3_endpoint = @options[:s3_endpoint].starts_with?('http') ? @options[:s3_endpoint] : "https://#{@options[:s3_endpoint]}"
|
19
|
+
|
20
|
+
|
20
21
|
if @options[:credentials].present?
|
21
22
|
credentials = @options[:credentials].symbolize_keys
|
22
23
|
::Aws::config[:credentials] = ::Aws::Credentials.new(credentials[:access_key_id], credentials[:secret_access_key])
|
23
24
|
::Aws.config[:region] = credentials[:region]
|
24
25
|
end
|
25
|
-
|
26
|
+
|
26
27
|
@aws_credentials = @options[:credentials] || {}
|
27
28
|
|
28
29
|
@s3_protocol = @options[:s3_protocol] ||
|
@@ -71,7 +72,7 @@ module Paperclip
|
|
71
72
|
def s3_host_name
|
72
73
|
host_name = @options[:s3_host_name] || "s3.amazonaws.com"
|
73
74
|
# host_name = host_name.call(self) if host_name.is_a?(Proc)
|
74
|
-
#
|
75
|
+
#
|
75
76
|
# host_name || s3_credentials[:s3_host_name] || "s3.amazonaws.com"
|
76
77
|
end
|
77
78
|
|
@@ -102,9 +103,9 @@ module Paperclip
|
|
102
103
|
|
103
104
|
def obtain_s3_instance_for(options)
|
104
105
|
instances = (Thread.current[:paperclip_s3_instances] ||= {})
|
105
|
-
instances[options] ||= s3_endpoint.present? ? ::Aws::S3.new(endpoint: s3_endpoint) : ::Aws.s3
|
106
|
+
instances[options] ||= s3_endpoint.present? ? ::Aws::S3::Client.new(endpoint: s3_endpoint) : ::Aws.s3
|
106
107
|
end
|
107
|
-
|
108
|
+
|
108
109
|
def s3_endpoint
|
109
110
|
@s3_endpoint
|
110
111
|
end
|
@@ -139,14 +140,14 @@ module Paperclip
|
|
139
140
|
log("saving #{path(style)}")
|
140
141
|
|
141
142
|
write_options = {
|
142
|
-
bucket: bucket_name,
|
143
|
-
key: path(style),
|
144
|
-
acl: 'public-read',
|
145
|
-
body: File.read(file.path),
|
143
|
+
bucket: bucket_name,
|
144
|
+
key: path(style),
|
145
|
+
acl: 'public-read',
|
146
|
+
body: File.read(file.path),
|
146
147
|
content_type: file.content_type
|
147
148
|
}
|
148
149
|
|
149
|
-
|
150
|
+
|
150
151
|
s3_interface.put_object(write_options)
|
151
152
|
rescue => e
|
152
153
|
log("Error: #{e.inspect}")
|
@@ -174,13 +175,13 @@ module Paperclip
|
|
174
175
|
@queued_for_delete = []
|
175
176
|
end
|
176
177
|
|
177
|
-
|
178
|
+
|
178
179
|
def copy_to_local_file(style, local_dest_path)
|
179
|
-
|
180
|
+
|
180
181
|
log("copying #{path(style)} to local file #{local_dest_path}")
|
181
182
|
local_file = ::File.open(local_dest_path, 'wb')
|
182
183
|
file = s3_interface.get_object(bucket: bucket_name, key: path(style))
|
183
|
-
file.body.pos = 0
|
184
|
+
file.body.pos = 0
|
184
185
|
local_file.write(file.body.read)
|
185
186
|
local_file.close
|
186
187
|
rescue AWS::Errors::Base => e
|
data/paperclip-aws-core.gemspec
CHANGED
@@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_dependency "aws-sdk-core"
|
20
|
+
|
21
|
+
spec.add_dependency "aws-sdk-core", '~> 2.0'
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.5"
|
24
24
|
spec.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-aws-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bill Centinaro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|