Commit 1bcd49f Jon Yurek
committed
1 parent 38a6b4d commit 1bcd49f Copy full SHA for 1bcd49f
File tree 1 file changed +5
-11
lines changed
lib/paperclip/io_adapters
1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -3,9 +3,8 @@ class DataUriAdapter < StringioAdapter
3
3
4
4
REGEXP = /^data:([-\w ]+\/ [-\w \+ ]+);base64,(.*)/
5
5
6
- def initialize ( target )
7
- @data_uri_parts = target . match ( REGEXP ) || [ ]
8
- deserialize
6
+ def initialize ( target_uri )
7
+ @target_uri = target_uri
9
8
cache_current_values
10
9
@tempfile = copy_to_tempfile
11
10
end
@@ -14,17 +13,12 @@ def initialize(target)
14
13
15
14
def cache_current_values
16
15
self . original_filename = 'base64.txt'
17
-
18
- @content_type = @data_uri_parts [ 1 ]
19
- @content_type ||= 'text/plain'
20
-
16
+ data_uri_parts ||= @target_uri . match ( REGEXP ) || [ ]
17
+ @content_type = data_uri_parts [ 1 ] || 'text/plain'
18
+ @target = StringIO . new ( Base64 . decode64 ( data_uri_parts [ 2 ] || '' ) )
21
19
@size = @target . size
22
20
end
23
21
24
- def deserialize
25
- @target = StringIO . new ( Base64 . decode64 ( @data_uri_parts [ 2 ] ) )
26
- end
27
-
28
22
end
29
23
end
30
24
You can’t perform that action at this time.
0 commit comments