echo_uploads 0.0.9 → 0.0.10

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/echo_uploads/mapper.rb +11 -8
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8858ce36c39e3bfef07642b2db1e6e7c581ddf0
4
- data.tar.gz: b60a1708ca9f78931cc6ecc6dee84a672388fb07
3
+ metadata.gz: b82e7d04075be6bf35940bee4a5d84cf7ad90434
4
+ data.tar.gz: 6ecd6ee756247943e964cc92d0b07f3b7c161492
5
5
  SHA512:
6
- metadata.gz: 0ad2e39ab5c892ebfcc9905c53a00473364eae67ad5aedbffe2cfc40075c2c7a9508a0dce04a2105ee7112e7cfad05b94f3de618fa69de494a887a3373afd25a
7
- data.tar.gz: 4c682d02a3760e23f3e7b9052234137dd4bd04632404ea36b0a8392d6836ae6b1b6376732502df27fe6527977cf67e0e9868bc9b01e1a1236ed8618ce311f6d7
6
+ metadata.gz: 140ef7a33f89e767c1b94ca128413198c0850f784ea7990fafdbde796e09406d64c5c0c8d765c317f14ad50f0eae833a1dbf7da84103f1daa60d7e04117043fa
7
+ data.tar.gz: eee115304fc5c1ee97d3b28cfea19ba7c498891b7a8ab49be3f06838181811ae4891e7be59a88686ebe41058b522b92d6e3d4d2be5eea601b9faac86f2e53489
@@ -24,15 +24,18 @@ module EchoUploads
24
24
  FileUtils.mkdir_p folder
25
25
  path = ::File.join(folder, SecureRandom.hex(15) + ext)
26
26
  yield path
27
- unless ::File.exists? path
28
- raise "Called echo_upload with the :map option, but failed to write a file to #{path}"
27
+ # The map callback might not write a file. That could happen if, for example, the
28
+ # input file is an invalid image. The best thing to do here is to fail silently.
29
+ # The application author should write code to handle the failure case, e.g. by
30
+ # appending to the ActiveRecord errors hash.
31
+ if ::File.exists? path
32
+ file = ::File.open path, 'rb'
33
+ mapped_file = ::EchoUploads::MappedFile.new(
34
+ tempfile: file, filename: @uploaded_file.original_filename
35
+ )
36
+ mapped_file.mapped_filename = ::File.basename path
37
+ outputs << mapped_file
29
38
  end
30
- file = ::File.open path, 'rb'
31
- mapped_file = ::EchoUploads::MappedFile.new(
32
- tempfile: file, filename: @uploaded_file.original_filename
33
- )
34
- mapped_file.mapped_filename = ::File.basename path
35
- outputs << mapped_file
36
39
  end
37
40
  end
38
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: echo_uploads
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarrett Colby