Skip to content

Commit 7132a5c

Browse files
committed
update to prod endpoint and include filename on uploads
1 parent deae9a2 commit 7132a5c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/file_uploader.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require 'logger'
33

44
class FileUploader
5-
UPLOAD_URL = "https://run.mocky.io/v3/86b7c197-1ac7-4d7b-a985-24255ae89722"
5+
UPLOAD_URL = "https://crowllectordb.onrender.com/api/v1/uploads" || ENV['MOCKSI_UPLOAD_URL']
66

77
def initialize(logger, client_uuid)
88
@logger = logger
@@ -44,7 +44,8 @@ def upload_file(tar_gz_file)
4444
end
4545

4646
def post_file(client, tar_gz_file)
47-
client.post(UPLOAD_URL,
47+
filename = File.basename(tar_gz_file)
48+
client.post("#{UPLOAD_URL}?filename=#{filename}",
4849
headers: { "x-client-id" => @client_uuid },
4950
body: File.read(tar_gz_file))
5051
rescue => e
@@ -53,10 +54,10 @@ def post_file(client, tar_gz_file)
5354
end
5455

5556
def log_upload_result(tar_gz_file, response)
56-
if response
57+
if response && response.status == 200
5758
@logger.info "Uploaded #{tar_gz_file}: #{response.status}"
5859
else
59-
@logger.error "Failed to upload #{tar_gz_file}"
60+
@logger.error "Failed to upload #{tar_gz_file}. Status: #{response&.status}, Body: #{response&.body}"
6061
end
6162
end
6263
end

0 commit comments

Comments
 (0)