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.
- checksums.yaml +4 -4
- data/lib/echo_uploads/mapper.rb +11 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b82e7d04075be6bf35940bee4a5d84cf7ad90434
|
4
|
+
data.tar.gz: 6ecd6ee756247943e964cc92d0b07f3b7c161492
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 140ef7a33f89e767c1b94ca128413198c0850f784ea7990fafdbde796e09406d64c5c0c8d765c317f14ad50f0eae833a1dbf7da84103f1daa60d7e04117043fa
|
7
|
+
data.tar.gz: eee115304fc5c1ee97d3b28cfea19ba7c498891b7a8ab49be3f06838181811ae4891e7be59a88686ebe41058b522b92d6e3d4d2be5eea601b9faac86f2e53489
|
data/lib/echo_uploads/mapper.rb
CHANGED
@@ -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
|
-
|
28
|
-
|
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
|