lib/ringcentral_sdk/helpers/fax.rb in ringcentral_sdk-0.1.1 vs lib/ringcentral_sdk/helpers/fax.rb in ringcentral_sdk-0.1.2

- old
+ new

@@ -73,12 +73,17 @@ unless File.file?(file_name.to_s) raise "File \"#{file_name.to_s}\" does not exist or cannot be read" end + file_bytes = RUBY_VERSION < '1.9' \ + ? File.open(file_name, 'rb') { |f| f.read } \ + : File.open(file_name, 'rb:BINARY') { |f| f.read } + file_part = base64_encode \ - ? MIME::Text.new(Base64.encode64(File.binread(file_name))) \ - : MIME::Application.new(File.binread(file_name)) + ? MIME::Text.new(Base64.encode64(file_bytes)) \ + : MIME::Application.new(file_bytes) + file_part.headers.delete('Content-Id') file_part.headers.set('Content-Type', get_file_content_type(file_name, content_type)) file_part.headers.set('Content-Disposition', get_attachment_content_disposition(file_name)) file_part.headers.set('Content-Transfer-Encoding', 'base64') if base64_encode return file_part \ No newline at end of file