From 7132a5c180ba445228ba3ac44644ac8a5709ab5e Mon Sep 17 00:00:00 2001 From: elg0nz Date: Sun, 18 Aug 2024 21:34:34 -0700 Subject: [PATCH] update to prod endpoint and include filename on uploads --- lib/file_uploader.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/file_uploader.rb b/lib/file_uploader.rb index ec14ae1..8332562 100644 --- a/lib/file_uploader.rb +++ b/lib/file_uploader.rb @@ -2,7 +2,7 @@ require 'logger' class FileUploader - UPLOAD_URL = "https://run.mocky.io/v3/86b7c197-1ac7-4d7b-a985-24255ae89722" + UPLOAD_URL = "https://crowllectordb.onrender.com/api/v1/uploads" || ENV['MOCKSI_UPLOAD_URL'] def initialize(logger, client_uuid) @logger = logger @@ -44,7 +44,8 @@ def upload_file(tar_gz_file) end def post_file(client, tar_gz_file) - client.post(UPLOAD_URL, + filename = File.basename(tar_gz_file) + client.post("#{UPLOAD_URL}?filename=#{filename}", headers: { "x-client-id" => @client_uuid }, body: File.read(tar_gz_file)) rescue => e @@ -53,10 +54,10 @@ def post_file(client, tar_gz_file) end def log_upload_result(tar_gz_file, response) - if response + if response && response.status == 200 @logger.info "Uploaded #{tar_gz_file}: #{response.status}" else - @logger.error "Failed to upload #{tar_gz_file}" + @logger.error "Failed to upload #{tar_gz_file}. Status: #{response&.status}, Body: #{response&.body}" end end end \ No newline at end of file