File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 2
2
require 'logger'
3
3
4
4
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' ]
6
6
7
7
def initialize ( logger , client_uuid )
8
8
@logger = logger
@@ -44,7 +44,8 @@ def upload_file(tar_gz_file)
44
44
end
45
45
46
46
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 } " ,
48
49
headers : { "x-client-id" => @client_uuid } ,
49
50
body : File . read ( tar_gz_file ) )
50
51
rescue => e
@@ -53,10 +54,10 @@ def post_file(client, tar_gz_file)
53
54
end
54
55
55
56
def log_upload_result ( tar_gz_file , response )
56
- if response
57
+ if response && response . status == 200
57
58
@logger . info "Uploaded #{ tar_gz_file } : #{ response . status } "
58
59
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 } "
60
61
end
61
62
end
62
63
end
You can’t perform that action at this time.
0 commit comments