I need to save a remote file a cloud storage server,so I must read this file to a file stream,I found this article : Open an IO stream from a local file or url the answer is :
require 'open-uri'
file_contents = open('local-file.txt') { |f| f.read }
web_contents = open('http://www.stackoverflow.com') {|f| f.read }
But the web_contents
is not right.Then I compare this action to a custom local file upload,which format is ASCII-8BIT
,the format is not same.so How can I get the correct stream from remote file .