Method: Cnvrg::Datafiles#upload_small_files_s3

Defined in:
lib/cnvrg/datafiles.rb

#upload_small_files_s3(url_path, file_path, content_type) ⇒ Object



901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
# File 'lib/cnvrg/datafiles.rb', line 901

def upload_small_files_s3(url_path, file_path, content_type)
  url = URI.parse(url_path)
  file = File.open(file_path, "rb")
  body = file.read
  begin
    Net::HTTP.start(url.host) do |http|
      http.send_request("PUT", url.request_uri, body, {
          "content-type" => content_type,
      })
    end
    return true
  rescue Interrupt
    return false
  rescue
    return false
  end
end