Method: Cnvrg::Datafiles#upload_exec_file

Defined in:
lib/cnvrg/datafiles.rb

#upload_exec_file(absolute_path, image_name, commit_id) ⇒ Object



690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
# File 'lib/cnvrg/datafiles.rb', line 690

def upload_exec_file(absolute_path, image_name, commit_id)
  file_name = File.basename absolute_path
  file_size = File.size(absolute_path).to_f
  content_type = "application/zip"
  begin
    upload_resp = Cnvrg::API.request("users/#{@owner}/images/" + "upload_config", 'POST_FILE', {relative_path: absolute_path,
                                                                                                file_name: file_name,
                                                                                                image_name: image_name,
                                                                                                file_size: file_size,
                                                                                                file_content_type: content_type,
                                                                                                project_slug: @project_slug,
                                                                                                commit_id: commit_id})
    # puts upload_resp
    if Cnvrg::CLI.is_response_success(upload_resp, false)
      if upload_resp["result"]["image"] == -1
        return -1
      end
      path = upload_resp["result"]["path"]
      s3_res = upload_small_files_s3(path, absolute_path, content_type)

    end
    if s3_res
      return upload_resp["result"]["id"]
    end
    return false
  rescue SignalException

    say "\nAborting"
    exit(1)
  end

end