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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With