Method: Morpheus::StorageProvidersInterface#download_file

Defined in:
lib/morpheus/api/storage_providers_interface.rb

#download_file(id, file_path, params = {}) ⇒ Object



81
82
83
84
85
86
87
88
89
# File 'lib/morpheus/api/storage_providers_interface.rb', line 81

def download_file(id, file_path, params={})
  raise "#{self.class}.download_file() passed a blank id!" if id.to_s == ''
  raise "#{self.class}.download_file() passed a blank file path!" if file_path.to_s == ''
  escaped_file_path = file_path.split("/").collect {|it| CGI::escape(it) }.join("/")
  url = "#{@base_url}/api/storage/buckets/#{CGI::escape(id.to_s)}" + "/download-file/#{escaped_file_path}".squeeze('/')
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts, false)
end