Method: Bixby::Client#exec_api_download

Defined in:
lib/bixby-client/client.rb

#exec_api_download(json_req, download_path) ⇒ JsonResponse

Execute the given API download request

Parameters:

  • json_req (JsonRequest)

    Request to download a file

  • download_path (String)

    Absolute filename to download requested file to

Returns:

  • (JsonResponse)


60
61
62
63
64
65
66
67
68
69
# File 'lib/bixby-client/client.rb', line 60

def exec_api_download(json_req, download_path)
  begin
    req = sign_request(json_req)
    File.open(download_path, "w") do |io|
      return HttpChannel.new(api_uri).execute_download(req) { |d| io << d; d.length }
    end
  rescue Curl::Err::CurlError => ex
    return JsonResponse.new("fail", ex.message)
  end
end