Class: Vagrant::Util::Uploader
- Inherits:
-
Object
- Object
- Vagrant::Util::Uploader
- Defined in:
- lib/vagrant/util/uploader.rb
Overview
This class uploads files using various protocols by subprocessing to cURL. cURL is a much more capable and complete download tool than a hand-rolled Ruby library, so we defer to its expertise.
Instance Method Summary collapse
-
#initialize(destination, file, options = nil) ⇒ Uploader
constructor
A new instance of Uploader.
- #upload! ⇒ Object
Constructor Details
#initialize(destination, file, options = nil) ⇒ Uploader
Returns a new instance of Uploader.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vagrant/util/uploader.rb', line 19 def initialize(destination, file, =nil) ||= {} @logger = Log4r::Logger.new("vagrant::util::uploader") @destination = destination.to_s @file = file.to_s @ui = [:ui] @request_method = [:method] if !@request_method @request_method = "PUT" end end |
Instance Method Details
#upload! ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vagrant/util/uploader.rb', line 32 def upload! data_proc = Vagrant::Util::CurlHelper.capture_output_proc(@logger, @ui) @logger.info("Uploader starting upload: ") @logger.info(" -- Source: #{@file}") @logger.info(" -- Destination: #{@destination}") = = {notify: :stderr} begin execute_curl(, , &data_proc) rescue Errors::UploaderError => e raise ensure @ui.clear_line if @ui end end |