update
This commit is contained in:
@@ -290,7 +290,7 @@ function envelope_to_json(env::msg_envelope_v1)
|
||||
payload_obj = Dict{String, Any}(
|
||||
"id" => payload.id,
|
||||
"dataname" => payload.dataname,
|
||||
"payload_type" => payload.type,
|
||||
"payload_type" => payload.payload_type,
|
||||
"transport" => payload.transport,
|
||||
"encoding" => payload.encoding,
|
||||
"size" => payload.size,
|
||||
@@ -643,7 +643,7 @@ function _serialize_data(data::Any, payload_type::String)
|
||||
error("Binary data must be binary (Vector{UInt8} or IOBuffer)")
|
||||
end
|
||||
else # Unknown type
|
||||
error("Unknown payload_type: $type")
|
||||
error("Unknown payload_type: $payload_type")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -967,11 +967,10 @@ function plik_oneshot_upload(file_server_url::String, filename::String, data::Ve
|
||||
http_response = nothing
|
||||
try
|
||||
http_response = HTTP.post(url_upload, headers, form)
|
||||
response_json = JSON.parse(http_response.body)
|
||||
catch e
|
||||
@error "Request failed" exception=e
|
||||
@error "Request failed" exception=e
|
||||
end
|
||||
|
||||
response_json = JSON.parse(http_response.body)
|
||||
fileid = response_json["id"]
|
||||
|
||||
# url of the uploaded data e.g. "http://192.168.1.20:8080/file/3F62E/4AgGT/test.zip"
|
||||
@@ -1035,19 +1034,19 @@ function plik_oneshot_upload(file_server_url::String, filepath::String)
|
||||
# Equivalent curl command: curl -X POST --header "X-UploadToken: UPLOAD_TOKEN" -F "file=@PATH_TO_FILE" http://localhost:8080/file/UPLOAD_ID
|
||||
url_upload = "$file_server_url/file/$uploadid"
|
||||
headers = ["X-UploadToken" => uploadtoken]
|
||||
response = open(filepath, "r") do file_stream
|
||||
http_response = open(filepath, "r") do file_stream
|
||||
form = HTTP.Form(Dict("file" => file_stream))
|
||||
|
||||
# Adding status_exception=false prevents 4xx/5xx from triggering 'catch'
|
||||
HTTP.post(url_upload, headers, form; status_exception = false)
|
||||
end
|
||||
|
||||
if !isnothing(response) && response.status == 200
|
||||
if !isnothing(http_response) && http_response.status == 200
|
||||
println("Success!")
|
||||
else
|
||||
println("Server returned an error code: ", response.status)
|
||||
println("Server returned an error code: ", http_response.status)
|
||||
end
|
||||
response_json = JSON.parse(response.body)
|
||||
response_json = JSON.parse(http_response.body)
|
||||
|
||||
fileid = response_json["id"]
|
||||
|
||||
@@ -1057,6 +1056,10 @@ function plik_oneshot_upload(file_server_url::String, filepath::String)
|
||||
return Dict("status" => http_response.status, "uploadid" => uploadid, "fileid" => fileid, "url" => url)
|
||||
end
|
||||
|
||||
function _get_payload_bytes(data)
|
||||
@error "did't implement yet"
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1074,6 +1077,4 @@ end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end # module
|
||||
|
||||
Reference in New Issue
Block a user