paperclip-aws-core 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd32454d50abf1f22884abcd2920a87f664fc670
4
- data.tar.gz: 5b9b2fe30fe9a9a01f3966fd2bd218d6f23318ce
3
+ metadata.gz: 429782143d9b3e9062e7bdc3b6a9d1294637a922
4
+ data.tar.gz: ba319bda74f25762ef11183239d70db820d8e7d6
5
5
  SHA512:
6
- metadata.gz: 6a93e1134a264d54cf359ddff043b6d4c808676aa846b70b4bab40a57c2fec281c53e11b71b47eb60f2195a7ff7c4181b6bdee19fac8e7abbfa5edb44a05326b
7
- data.tar.gz: 5cdd9aa851649df3b0c509368a03351a1c6f2e22e1ecc1caabac57bf0a7588fc65ed76e160cb2a95e8c4a83a5f0e156dbbae02ea2e3889b6ce66fc5933197ffd
6
+ metadata.gz: 996c5592a8b449b5a26e56b8cf9d916cbc3a78ff64f8ddacac46b7201ae1438d8ad4c627c3629f44a9cc8b6eee9dc10a7929a7e64c155772e91368e4006737d0
7
+ data.tar.gz: 5367ed7fcededf6671367697ff0aa55df02dee0db229c8d39fe99b2fe26de6ee42777e1f13b370d2f25e65d0fe5b69ea43de9dbebb2fdd913cf3f27ea29da78d
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.0
@@ -1,7 +1,7 @@
1
1
  module Paperclip
2
2
  module Aws
3
3
  module Core
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
7
  end
@@ -11,21 +11,6 @@ module Paperclip
11
11
  raise e
12
12
  end unless defined?(Aws)
13
13
 
14
- # TODO: Covert the Log Formating
15
- # # Overriding log formatter to make sure it return a UTF-8 string
16
- # if defined?(AWS::Core::LogFormatter)
17
- # AWS::Core::LogFormatter.class_eval do
18
- # def summarize_hash(hash)
19
- # hash.map { |key, value| ":#{key}=>#{summarize_value(value)}".force_encoding('UTF-8') }.sort.join(',')
20
- # end
21
- # end
22
- # elsif defined?(AWS::Core::ClientLogging)
23
- # AWS::Core::ClientLogging.class_eval do
24
- # def sanitize_hash(hash)
25
- # hash.map { |key, value| "#{sanitize_value(key)}=>#{sanitize_value(value)}".force_encoding('UTF-8') }.sort.join(',')
26
- # end
27
- # end
28
- # end
29
14
 
30
15
  base.instance_eval do
31
16
  @s3_options = @options[:s3_options] || {}
@@ -138,10 +123,7 @@ module Paperclip
138
123
  @queued_for_write.each do |style, file|
139
124
  begin
140
125
  log("saving #{path(style)}")
141
- acl = @s3_permissions[style] || @s3_permissions[:default]
142
- acl = acl.call(self, style) if acl.respond_to?(:call)
143
-
144
-
126
+
145
127
  write_options = {
146
128
  bucket: bucket_name,
147
129
  key: path(style),
@@ -149,31 +131,14 @@ module Paperclip
149
131
  body: File.read(file.path),
150
132
  content_type: file.content_type
151
133
  }
152
-
153
-
154
- if @s3_server_side_encryption
155
- write_options[:server_side_encryption] = @s3_server_side_encryption
156
- end
157
134
 
158
- style_specific_options = styles[style]
159
-
160
- if style_specific_options
161
- merge_s3_headers( style_specific_options[:s3_headers], @s3_headers, @s3_metadata) if style_specific_options[:s3_headers]
162
- @s3_metadata.merge!(style_specific_options[:s3_metadata]) if style_specific_options[:s3_metadata]
163
- end
164
-
165
- write_options[:metadata] = @s3_metadata unless @s3_metadata.empty?
166
- write_options.merge!(@s3_headers)
167
-
168
- # TODO: Change out for API Call
169
135
 
170
136
  s3_interface.put_object(write_options)
171
- # s3_object(style).write(file, write_options)
172
137
  rescue ::Aws::S3::Errors::NoSuchBucket => e
173
138
  # create_bucket
174
139
  # retry
175
140
  ensure
176
- # file.rewind
141
+ file.rewind
177
142
  end
178
143
  end
179
144
 
@@ -196,16 +161,16 @@ module Paperclip
196
161
 
197
162
 
198
163
  def copy_to_local_file(style, local_dest_path)
199
- # TODO: This whole function
200
164
 
201
- # log("copying #{path(style)} to local file #{local_dest_path}")
202
- # local_file = ::File.open(local_dest_path, 'wb')
203
- # file = s3_object(style)
204
- # local_file.write(file.read)
205
- # local_file.close
206
- # rescue AWS::Errors::Base => e
207
- # warn("#{e} - cannot copy #{path(style)} to local file #{local_dest_path}")
208
- # false
165
+ log("copying #{path(style)} to local file #{local_dest_path}")
166
+ local_file = ::File.open(local_dest_path, 'wb')
167
+ file = s3_interface.get_object(bucket: bucket_name, key: path(style))
168
+ file.body.pos = 0
169
+ local_file.write(file.body.read)
170
+ local_file.close
171
+ rescue AWS::Errors::Base => e
172
+ warn("#{e} - cannot copy #{path(style)} to local file #{local_dest_path}")
173
+ false
209
174
  end
210
175
 
211
176
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-aws-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-04-22 00:00:00.000000000 Z
11
+ date: 2014-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core
@@ -60,6 +60,7 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
+ - ".ruby-version"
63
64
  - Gemfile
64
65
  - LICENSE.txt
65
66
  - README.md