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.
@@ -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 :include_files => false
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
 
@@ -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
- send "#{name}_content_type=", MIME::Types.type_for(File.basename(url.path)).first.content_type
78
- send "#{name}=", StringIO.new(connection.get_attachment(url.path,
79
- 'Accept' => send("#{name}_content_type"))), changed
80
- send "#{name}_file_name=", File.basename(url.path)
81
- send "#{name}_content_type=", MIME::Types.type_for(File.basename(url.path)).first.content_type
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}=", nil, changed
85
+ send "#{name}=", nil, changed
84
86
  end
85
87
  end
86
88
 
@@ -1,3 +1,3 @@
1
1
  module EncodedAttachment
2
- VERSION = "0.1.6" unless defined? EncodedAttachment::VERSION
2
+ VERSION = "0.1.7" unless defined? EncodedAttachment::VERSION
3
3
  end
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 6
10
- version: 0.1.6
9
+ - 7
10
+ version: 0.1.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nick Ragaz