Net::SFTP Transfer Mode (Binary vs Text)

Is there a way using the Net::SFTP Library in Ruby (API Link) to set the Transfer Mode to Binary? I am unforunately on a windows system and am uploading a UTF-8 file to a Unix system. The ruby library apparently using Text as the default Transfer Mode and causing my encoding to get garbled with ANSI. If I can force Binary mode the UTF-8 should remain in tact.

Thanks

Answers


I think I found a workaround.

Before, we were doing something like this:

sftp.file.open(filename) do |f|
  f.puts(data)
end

We changed this to use a StringIO object, like so:

require 'stringio'
io = StringIO.new(data)
sftp.upload!(io, filename)

Using the upload! method seems to respect the encoding as it just copies the bytes.

Hope that helps.


Need Your Help

Using Microsoft OCR Library with JS/jQuery in VS 2013

javascript cordova visual-studio-2013 ocr visual-studio-cordova

I am currently working on a windows 8.1 application and I am using web languages and mostly jQuery (Cordova type project) as it might be used on other platforms.

oracle - to_Date format

sql database oracle date

What format would you use to convert this CHAR value into a date?