Skip to content

Commit

Permalink
update to prod endpoint and include filename on uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
elg0nz committed Aug 19, 2024
1 parent deae9a2 commit 6706049
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/file_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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/upload" || ENV['MOCKSI_UPLOAD_URL']

def initialize(logger, client_uuid)
@logger = logger
Expand Down Expand Up @@ -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
Expand All @@ -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

0 comments on commit 6706049

Please sign in to comment.