Skip to content

Commit

Permalink
try Ruby 1.8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
John Wang committed Jun 1, 2015
1 parent 2ede35a commit 87eb52a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/ringcentral_sdk/helpers/fax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ def get_file_part(file_name=nil, content_type=nil, base64_encode=false)
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))
Expand Down

0 comments on commit 87eb52a

Please sign in to comment.