Method: Cnvrg::Files#upload_small_files_s3

Defined in:
lib/cnvrg/files.rb

#upload_small_files_s3(url_path, file_path, content_type) ⇒ Object



330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# File 'lib/cnvrg/files.rb', line 330

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|
      if !Helpers.is_verify_ssl
        http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      end
      http.send_request("PUT", url.request_uri, body, {
          "content-type" => content_type,
      })
    end
    return true
  rescue Interrupt
    return false
  rescue => e
    puts e
    return false
  end
end