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.
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vagrant/util/uploader.rb', line 24 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 @request_method = @request_method.to_s.upcase end |
Instance Method Details
#upload! ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/vagrant/util/uploader.rb', line 38 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 |