pothoven-attachment_fu 3.2.18 → 3.3.0

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjYxMDgwMTI0OTMwODNmMjU0NWM1MjFlY2MxZjM0M2MyYjM1NDM1NQ==
4
+ YjRhMjdkMWRkOThhNDgyNDdhZjIwMTA3N2JjM2ZkN2Q1MjVmODljNA==
5
5
  data.tar.gz: !binary |-
6
- Mjc2MDNkNDU2MDViZjU1Yjc1MjUyZmE4NjM5OTU1MDJiMjBlZjc0Yw==
6
+ NjY2Yjg2MzQ1ZDU3MmY0YzVmNGIzMTBhNTIxYzBhM2Q0ZDI5MTEwMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmRhNDIxZmJhM2E0NzFlNWNmOWMwOWI5ODZlNmY3MWYxNjY4NmJkOGJkMzVh
10
- MjNjMTNhODI0Y2U2NTBkMjJjOWZjN2Q2NTBjZmU0N2FlMTVhNTE2NDFkZTcx
11
- Mzk1NWQ5YWQzNDFiODIxNDcyODJhMDdjNTRiYzY5NjEyYjljNjc=
9
+ MTI4OGU5OWJmZTUzY2E5YmNlMTVmZGY5MTVkYWVkNWQyNjg3OTY3MDJkYjY1
10
+ ZTg2MmZjMzI3MzQ4MjJkM2RhY2RiZTFlMTUxOTkzMmFmNzY5NTA1NjgyMjVk
11
+ ZmIyNjk1ZGMwM2I2OTI0YmNjZDcyYTExYzdkZmM1ZWM2ZjA2OTc=
12
12
  data.tar.gz: !binary |-
13
- OTE4ODYwZWM0YjdiNjAzN2U2MmQzODg3YTg2NzgwYWRmNzI5NTM4OGQyOGM5
14
- ODBhMTdiZDM3NDM2YmQ1NDA0Njk2ODVhMDc0ZmJkYWRmOWExYmY2YmRmN2Vh
15
- YmZjYTlkMWE1MmU5MThlNzM5MGRiY2Y5NThkZDcxYWU2NzkzYjA=
13
+ OGYyZGI4NjYyYzRhMmM0NDE5ZmFiZTNmMzRjYTA2YTI5Njk2NzBjYWI4N2Jh
14
+ ZDMyN2ZjMTI1ZTNhMDE4ZGQ1NzczNjU2ZDk2NTMxMWJhMWZjMzg0NGNjYWJi
15
+ NGU3ZjlkODkyZmU4ZDI1ZTE0MDk1MzJiMzU3N2Y3ODA4MWI4NzI=
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ * Apr 19, 2017 *
2
+ * Pull in changes from bacrossland to upgrade from aws-s3 gem to aws-sdk gem *
3
+ * Bump version to 3.3.0 to try to protect auto builds using s3 gem from breaking *
4
+
1
5
  * May 27, 2016 *
2
6
  * Pull in changes from gaugausi to fix for non-existent #where interface in Rails 2.3 *
3
7
 
data/README.rdoc CHANGED
@@ -1,6 +1,8 @@
1
1
  = attachment-fu
2
2
 
3
- {<img src="https://badge.fury.io/rb/pothoven-attachment_fu.svg" alt="Gem Version" />}[http://badge.fury.io/rb/pothoven-attachment_fu]
3
+ {<img src="https://badge.fury.io/rb/pothoven-attachment_fu.svg" alt="Gem Version" />}[https://rubygems.org/gems/pothoven-attachment_fu]
4
+ {<img src="http://ruby-gem-downloads-badge.herokuapp.com/pothoven-attachment_fu?type=total&color=brightgreen" />}[https://rubygems.org/gems/pothoven-attachment_fu]
5
+ {<img src="http://ruby-gem-downloads-badge.herokuapp.com/pothoven-attachment_fu?color=brightgreen&label=for-this-version" />}[https://rubygems.org/gems/pothoven-attachment_fu]
4
6
 
5
7
  attachment_fu is a plugin by Rick Olson (aka technoweenie
6
8
  http://techno-weenie.net) and is the successor to acts_as_attachment. To get a
@@ -7,8 +7,7 @@ module Technoweenie # :nodoc:
7
7
  #
8
8
  # == Requirements
9
9
  #
10
- # Requires the {AWS::S3 Library}[http://amazon.rubyforge.org] for S3 by Marcel Molina Jr. installed either
11
- # as a gem or a as a Rails plugin.
10
+ # Requires the aws-sdk-v1 gem.
12
11
  #
13
12
  # == Configuration
14
13
  #
@@ -173,13 +172,12 @@ module Technoweenie # :nodoc:
173
172
  class ConfigFileNotFoundError < StandardError; end
174
173
 
175
174
  def self.included(base) #:nodoc:
176
- mattr_reader :bucket_name, :s3_config
175
+ mattr_reader :bucket_name, :s3_config, :s3_conn, :bucket
177
176
 
178
177
  begin
179
- require 'aws/s3'
180
- include AWS::S3
178
+ require 'aws-sdk-v1'
181
179
  rescue LoadError
182
- raise RequiredLibraryNotFoundError.new('AWS::S3 could not be loaded')
180
+ raise RequiredLibraryNotFoundError.new('aws-sdk-v1 could not be loaded. Make sure the gem is installed.')
183
181
  end
184
182
 
185
183
  begin
@@ -198,9 +196,10 @@ module Technoweenie # :nodoc:
198
196
  end
199
197
  base.class_eval(eval_string, __FILE__, __LINE__)
200
198
 
201
- Base.establish_connection!(s3_config.slice(:access_key_id, :secret_access_key, :server, :port, :use_ssl, :persistent, :proxy))
199
+ @@s3_conn = AWS::S3.new(s3_config.slice(:access_key_id, :secret_access_key))
200
+ @@bucket = s3_conn.buckets[s3_config[:bucket_name]]
202
201
 
203
- # Bucket.create(@@bucket_name)
202
+ #Base.establish_connection!(s3_config.slice(:access_key_id, :secret_access_key, :server, :port, :use_ssl, :persistent, :proxy))
204
203
 
205
204
  base.before_update :rename_file
206
205
  end
@@ -210,7 +209,7 @@ module Technoweenie # :nodoc:
210
209
  end
211
210
 
212
211
  def self.hostname
213
- @hostname ||= s3_config[:server] || AWS::S3::DEFAULT_HOST
212
+ @hostname ||= s3_config[:server] || 's3.amazonaws.com'
214
213
  end
215
214
 
216
215
  def self.port_string
@@ -324,9 +323,12 @@ module Technoweenie # :nodoc:
324
323
  # @photo.authenticated_s3_url('thumbnail', :expires_in => 5.hours, :use_ssl => true)
325
324
  def authenticated_s3_url(*args)
326
325
  options = args.extract_options!
327
- options[:expires_in] = options[:expires_in].to_i if options[:expires_in]
326
+ options[:expires] = options[:expires_in].to_i if options[:expires_in]
327
+ options[:secure] = options[:use_ssl] if options[:use_ssl]
328
+ options.delete(:expires_in) if options[:expires_in]
329
+ options.delete(:use_ssl) if options[:use_ssl]
328
330
  thumbnail = args.shift
329
- S3Object.url_for(full_filename(thumbnail), bucket_name, options)
331
+ bucket.objects[full_filename(thumbnail)].url_for(:read, options).to_s
330
332
  end
331
333
 
332
334
  def create_temp_file
@@ -335,9 +337,9 @@ module Technoweenie # :nodoc:
335
337
 
336
338
  def current_data
337
339
  if attachment_options[:encrypted_storage] && self.respond_to?(:encryption_key) && self.encryption_key != nil
338
- EncryptedData.decrypt_data(S3Object.value(full_filename, bucket_name), self.encryption_key)
340
+ EncryptedData.decrypt_data(bucket.objects[full_filename].read, self.encryption_key)
339
341
  else
340
- S3Object.value full_filename, bucket_name
342
+ bucket.objects[full_filename].read
341
343
  end
342
344
  end
343
345
 
@@ -360,21 +362,28 @@ module Technoweenie # :nodoc:
360
362
  protected
361
363
  # Called in the after_destroy callback
362
364
  def destroy_file
363
- S3Object.delete full_filename, bucket_name
365
+ obj = bucket.objects[full_filename]
366
+ obj.delete
364
367
  end
365
368
 
366
369
  def rename_file
367
370
  return unless @old_filename && @old_filename != filename
368
371
 
369
372
  old_full_filename = File.join(base_path, @old_filename)
373
+ old_obj = bucket.objects[old_full_filename]
374
+ obj = bucket.objects[full_filename]
375
+
376
+ if attachment_options[:encrypted_storage]
377
+ obj.copy_from(old_obj, {:cache_control => attachment_options[:cache_control],
378
+ :acl => attachment_options[:s3_access],
379
+ :server_side_encryption => :aes256,
380
+ :content_disposition => "attachment; filename=\"#{filename}\""})
381
+ else
382
+ obj.copy_from(old_obj, {:cache_control => attachment_options[:cache_control],
383
+ :acl => attachment_options[:s3_access]})
384
+ end
370
385
 
371
- S3Object.rename(
372
- old_full_filename,
373
- full_filename,
374
- bucket_name,
375
- :access => attachment_options[:s3_access]
376
- )
377
-
386
+ old_obj.delete
378
387
  @old_filename = nil
379
388
  true
380
389
  end
@@ -382,25 +391,19 @@ module Technoweenie # :nodoc:
382
391
  def save_to_storage
383
392
  if save_attachment?
384
393
  if attachment_options[:encrypted_storage]
385
- S3Object.store(
386
- full_filename,
387
- (temp_path ? File.open(temp_path) : temp_data),
388
- bucket_name,
389
- :content_type => content_type,
390
- :cache_control => attachment_options[:cache_control],
391
- :access => attachment_options[:s3_access],
392
- 'x-amz-server-side-encryption' => 'AES256',
393
- 'Content-Disposition' => "attachment; filename=\"#{filename}\""
394
- )
394
+ obj = bucket.objects[full_filename]
395
+ obj.write(:file => (temp_path ? File.open(temp_path) : temp_data),
396
+ :cache_control => attachment_options[:cache_control],
397
+ :acl => attachment_options[:s3_access],
398
+ :server_side_encryption => :aes256,
399
+ :content_disposition => "attachment; filename=\"#{filename}\""
400
+ )
395
401
  else
396
- S3Object.store(
397
- full_filename,
398
- (temp_path ? File.open(temp_path) : temp_data),
399
- bucket_name,
400
- :content_type => content_type,
401
- :cache_control => attachment_options[:cache_control],
402
- :access => attachment_options[:s3_access]
403
- )
402
+ obj = bucket.objects[full_filename]
403
+ obj.write(:file => (temp_path ? File.open(temp_path) : temp_data),
404
+ :cache_control => attachment_options[:cache_control],
405
+ :acl => attachment_options[:s3_access]
406
+ )
404
407
  end
405
408
  end
406
409
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pothoven-attachment_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.18
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Olson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-05-27 00:00:00.000000000 Z
12
+ date: 2017-04-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: This is a fork of Rick Olson's attachment_fu adding Ruby 1.9 and Rails
15
15
  3.2 and Rails 4 support as well as some other enhancements.
@@ -62,7 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  - - ! '>='
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
- requirements: []
65
+ requirements:
66
+ - aws-sdk-v1, ~> 1.61.0
66
67
  rubyforge_project: nowarning
67
68
  rubygems_version: 2.4.8
68
69
  signing_key: