Class: HighriseAssist::FileTransfer
- Inherits:
-
Object
- Object
- HighriseAssist::FileTransfer
- Defined in:
- lib/highrise_assist/file_transfer.rb
Instance Method Summary collapse
- #download(from, to) ⇒ Object
-
#initialize(options) ⇒ FileTransfer
constructor
A new instance of FileTransfer.
- #upload(from, to) ⇒ Object
Constructor Details
#initialize(options) ⇒ FileTransfer
Returns a new instance of FileTransfer.
5 6 7 8 9 10 11 |
# File 'lib/highrise_assist/file_transfer.rb', line 5 def initialize() @options = @http = Net::HTTP::Persistent.new('highrise-file-transfer') @http.verify_mode = OpenSSL::SSL::VERIFY_NONE @http end |
Instance Method Details
#download(from, to) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/highrise_assist/file_transfer.rb', line 13 def download(from, to) uri = URI.parse(from) get_request = Net::HTTP::Get.new(uri.request_uri) get_request.basic_auth @options[:token], '' @http.request(uri, get_request) do |response| open(to, 'w') do |io| response.read_body { |chunk| io.write chunk } end end end |
#upload(from, to) ⇒ Object
26 27 28 |
# File 'lib/highrise_assist/file_transfer.rb', line 26 def upload(from, to) raise NotImplementedError end |