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