shrine-transloadit 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shrine/plugins/transloadit.rb +7 -4
- data/shrine-transloadit.gemspec +1 -1
- 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: 109ddcc53c8f5fb6ab3ee67461ed619ffec34774
|
4
|
+
data.tar.gz: 12379b0d444076bbf9b651d03528e4469f6931d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75aec7f284c57b810adda9ab7c54511958d19310674e15f489cce979f034e76966362baedc2402d3f3873c71f27cb8a8a73ffcc45b5d5dfd2abead88105778a9
|
7
|
+
data.tar.gz: 2a338c8f79d6cf7312f15d6880c4d07fdf59f4a21cdc40a2ce653403ea0f7befb82a31b7c275f8e3ac3415ce837cbe0f55b504f5b96325fc7f4de688fda78e23
|
@@ -36,8 +36,7 @@ class Shrine
|
|
36
36
|
data = response["fields"]["attacher"]
|
37
37
|
attacher = self.load(data)
|
38
38
|
cached_file = attacher.uploaded_file(data["attachment"])
|
39
|
-
|
40
|
-
attacher.transloadit_save(response)
|
39
|
+
attacher.transloadit_save(response, valid: attacher.get == cached_file)
|
41
40
|
attacher
|
42
41
|
end
|
43
42
|
|
@@ -62,7 +61,7 @@ class Shrine
|
|
62
61
|
swap(cached_file)
|
63
62
|
end
|
64
63
|
|
65
|
-
def transloadit_save(response)
|
64
|
+
def transloadit_save(response, valid: true)
|
66
65
|
if versions = response["fields"]["versions"]
|
67
66
|
stored_file = versions.inject({}) do |hash, (name, key)|
|
68
67
|
result = response["results"].fetch(key)[0]
|
@@ -74,7 +73,11 @@ class Shrine
|
|
74
73
|
stored_file = store.transloadit_uploaded_file(result)
|
75
74
|
end
|
76
75
|
|
77
|
-
|
76
|
+
if valid
|
77
|
+
update(stored_file)
|
78
|
+
else
|
79
|
+
_delete(stored_file, phase: :abort)
|
80
|
+
end
|
78
81
|
end
|
79
82
|
end
|
80
83
|
|
data/shrine-transloadit.gemspec
CHANGED