encoded_attachment 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/activerecord/base.rb +1 -1
- data/lib/activeresource/base.rb +8 -6
- data/lib/encoded_attachment/version.rb +1 -1
- metadata +3 -3
data/lib/activerecord/base.rb
CHANGED
@@ -16,7 +16,7 @@ module EncodedAttachment
|
|
16
16
|
end
|
17
17
|
|
18
18
|
define_method "to_xml_with_encoded_#{name}" do |*args|
|
19
|
-
# You can exclude file tags completely by using :
|
19
|
+
# You can exclude file tags completely by using :include_attachments => false
|
20
20
|
# If :send_urls => true, force file encoding using :encode => true
|
21
21
|
options, block = args
|
22
22
|
|
data/lib/activeresource/base.rb
CHANGED
@@ -74,13 +74,15 @@ module EncodedAttachment
|
|
74
74
|
changed = (changed.nil? || changed) ? true : false
|
75
75
|
if file_url
|
76
76
|
url = URI.parse(file_url.to_s)
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
77
|
+
content_type = MIME::Types.type_for(File.basename(url.path)).first.content_type
|
78
|
+
|
79
|
+
io = StringIO.new(connection.get_attachment(url.path, 'Accept' => content_type))
|
80
|
+
io.original_filename = File.basename(url.path)
|
81
|
+
io.content_type = content_type
|
82
|
+
|
83
|
+
send "#{name}=", io, changed
|
82
84
|
else
|
83
|
-
send "#{name}=",
|
85
|
+
send "#{name}=", nil, changed
|
84
86
|
end
|
85
87
|
end
|
86
88
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: encoded_attachment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 7
|
10
|
+
version: 0.1.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nick Ragaz
|