Method: Cnvrg::Files#download_image

Defined in:
lib/cnvrg/files.rb

#download_image(file_path_to_store, image_slug, owner) ⇒ Object



314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/cnvrg/files.rb', line 314

def download_image(file_path_to_store, image_slug, owner)


  download_resp = Cnvrg::API.request("users/#{owner}/images/#{image_slug}/" + "download", 'GET')
  path = download_resp["result"]["path"]

  if Cnvrg::CLI.is_response_success(download_resp, false)
    begin
      open(file_path_to_store, 'wb') do |file|
        file << open(path).read
      end

      return true
    rescue => e
      return false
    end

    return true
  else
    return false
  end


end