shrine 3.2.1 → 3.2.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of shrine might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9762e59a3b310aecf9e4c2789e35df5b814826cf1db60e258faed44fdb1efe6
4
- data.tar.gz: 857d1abbb026440d32e105cbbd248a89792e4f7b094b7e9509c2a735de32dfe0
3
+ metadata.gz: 26dd77c39f9d5b7cc4240eacea23823453959aad469acc1d86571f129c24c347
4
+ data.tar.gz: 9c25f9de3f8c8be835e096da01b47c0636e03158b423a306b89895de05ca4294
5
5
  SHA512:
6
- metadata.gz: b295b7d382c7e73384fcb69f3df1b049427ea2c40e5a84bd4505295cdc8e423aee7e8d76d7b153ecf7c5e0dbea6208d1a693448ee6e97037a9ebeff5fb9ebf46
7
- data.tar.gz: 8263b3c88336b7ab9e7744ab3de1cae8cc00474af72e95d7c85fca96f89f900c6f347dc7ceaf440143ee5410bd7d00a8a85dab342644fb052ccdf81b974a185e
6
+ metadata.gz: 4ae941f20c889d15300bb0a3bb522f8ad9f0cbd9bb80578246bc4d5ed37b1177ecc911172a405872919210bdaa05b1e67f23d77fc97d9c827ef85b01898dd336
7
+ data.tar.gz: 16fbafcc5d29e70f6d0d4a36fc2123a4a8f705345021b00e87c863826d73970a7bd8116aa19ad5c3a2a03763b0e5e435398ae15a21428d0b932c52a7bb648f8e
@@ -1,3 +1,7 @@
1
+ ## 3.2.2 (2020-08-05)
2
+
3
+ * `s3` – Fix `S3#open` not working on aws-sdk-core 3.104 and above (@janko)
4
+
1
5
  ## 3.2.1 (2020-01-12)
2
6
 
3
7
  * `derivation_endpoint` – Use `Rack::Files` constant on Rack >= 2.1 (@janko)
@@ -0,0 +1,14 @@
1
+ ---
2
+ title: Shrine 3.2.2
3
+ ---
4
+
5
+ ## Bug fixes
6
+
7
+ * aws-sdk-core 3.104.0 introduced a backwards incompatible changes that caused
8
+ `Shrine::Storage::S3#open` to start raising an exception.
9
+
10
+ ```
11
+ NoMethodError: undefined method `bytesize' for #<Array:0x000000000a721be0>
12
+ ```
13
+
14
+ This has now been fixed.
@@ -103,7 +103,7 @@ class Shrine
103
103
  #
104
104
  # [`Aws::S3::Object#get`]: http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#get-instance_method
105
105
  def open(id, rewindable: true, **options)
106
- chunks, length = get_object(object(id), options)
106
+ chunks, length = get(object(id), options)
107
107
 
108
108
  Down::ChunkedIO.new(chunks: chunks, rewindable: rewindable, size: length)
109
109
  rescue Aws::S3::Errors::NoSuchKey
@@ -279,22 +279,36 @@ class Shrine
279
279
  end
280
280
  end
281
281
 
282
- # Aws::S3::Object#get doesn't allow us to get the content length of the
283
- # object before the content is downloaded, so we hack our way around it.
284
- def get_object(object, params)
285
- req = client.build_request(:get_object, bucket: bucket.name, key: object.key, **params)
282
+ if Gem::Version.new(Aws::CORE_GEM_VERSION) >= Gem::Version.new("3.104.0")
283
+ def get(object, params)
284
+ enum = object.enum_for(:get, **params)
286
285
 
287
- body = req.enum_for(:send_request)
288
- begin
289
- body.peek # start the request
290
- rescue StopIteration
291
- # the S3 object is empty
286
+ begin
287
+ content_length = Integer(enum.peek.last["content-length"])
288
+ rescue StopIteration
289
+ content_length = 0
290
+ end
291
+
292
+ chunks = Enumerator.new { |y| loop { y << enum.next.first } }
293
+
294
+ [chunks, content_length]
292
295
  end
296
+ else
297
+ def get(object, params)
298
+ req = client.build_request(:get_object, bucket: bucket.name, key: object.key, **params)
299
+
300
+ body = req.enum_for(:send_request)
301
+ begin
302
+ body.peek # start the request
303
+ rescue StopIteration
304
+ # the S3 object is empty
305
+ end
293
306
 
294
- content_length = Integer(req.context.http_response.headers["Content-Length"])
295
- chunks = Enumerator.new { |y| loop { y << body.next } }
307
+ content_length = Integer(req.context.http_response.headers["Content-Length"])
308
+ chunks = Enumerator.new { |y| loop { y << body.next } }
296
309
 
297
- [chunks, content_length]
310
+ [chunks, content_length]
311
+ end
298
312
  end
299
313
 
300
314
  # The file is copyable if it's on S3 and on the same Amazon account.
@@ -8,7 +8,7 @@ class Shrine
8
8
  module VERSION
9
9
  MAJOR = 3
10
10
  MINOR = 2
11
- TINY = 1
11
+ TINY = 2
12
12
  PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shrine
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-15 00:00:00.000000000 Z
11
+ date: 2020-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down
@@ -457,6 +457,7 @@ files:
457
457
  - doc/release_notes/3.1.0.md
458
458
  - doc/release_notes/3.2.0.md
459
459
  - doc/release_notes/3.2.1.md
460
+ - doc/release_notes/3.2.2.md
460
461
  - doc/retrieving_uploads.md
461
462
  - doc/securing_uploads.md
462
463
  - doc/storage/file_system.md
@@ -551,7 +552,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
551
552
  - !ruby/object:Gem::Version
552
553
  version: '0'
553
554
  requirements: []
554
- rubygems_version: 3.1.2
555
+ rubygems_version: 3.1.1
555
556
  signing_key:
556
557
  specification_version: 4
557
558
  summary: Toolkit for file attachments in Ruby applications