This commit is contained in:
2026-02-25 07:29:42 +07:00
parent 14b3790251
commit 6a42ba7e43
2 changed files with 9 additions and 7 deletions

View File

@@ -13,3 +13,5 @@ Role: Principal Systems Architect & Lead Software Engineer.Objective: Implement
Create a walkthrough for Julia service-A service sending a mix-content chat message to Julia service-B. the chat message must includes
I update architecture.md and NATSBridge.jl. Use them as ground truth and update implementation.md accordingly. Also look for any inconsistency.

View File

@@ -914,7 +914,7 @@ retrieves an upload ID and token, then uploads the file data as multipart form d
# Arguments:
- `file_server_url::String` - Base URL of the plik server (e.g., `"http://localhost:8080"`)
- `filename::String` - Name of the file being uploaded
- `dataname::String` - Name of the file being uploaded
- `data::Vector{UInt8}` - Raw byte data of the file content
# Return:
@@ -929,17 +929,17 @@ retrieves an upload ID and token, then uploads the file data as multipart form d
using HTTP, JSON
fileserver_url = "http://localhost:8080"
filename = "test.txt"
dataname = "test.txt"
data = Vector{UInt8}("hello world")
# Upload to local plik server
result = plik_oneshot_upload(file_server_url, filename, data)
result = plik_oneshot_upload(file_server_url, dataname, data)
# Access the result as a Dict
# result["status"], result["uploadid"], result["fileid"], result["url"]
```
"""
function plik_oneshot_upload(file_server_url::String, filename::String, data::Vector{UInt8})
function plik_oneshot_upload(file_server_url::String, dataname::String, data::Vector{UInt8})
# ----------------------------------------- get upload id ---------------------------------------- #
# Equivalent curl command: curl -X POST -d '{ "OneShot" : true }' http://localhost:8080/upload
@@ -953,7 +953,7 @@ function plik_oneshot_upload(file_server_url::String, filename::String, data::Ve
# ------------------------------------------ upload file ----------------------------------------- #
# Equivalent curl command: curl -X POST --header "X-UploadToken: UPLOAD_TOKEN" -F "file=@PATH_TO_FILE" http://localhost:8080/file/UPLOAD_ID
file_multipart = HTTP.Multipart(filename, IOBuffer(data), "application/octet-stream") # Plik won't accept raw bytes upload
file_multipart = HTTP.Multipart(dataname, IOBuffer(data), "application/octet-stream") # Plik won't accept raw bytes upload
url_upload = "$file_server_url/file/$uploadid"
headers = ["X-UploadToken" => uploadtoken]
@@ -973,7 +973,7 @@ function plik_oneshot_upload(file_server_url::String, filename::String, data::Ve
fileid = response_json["id"]
# url of the uploaded data e.g. "http://192.168.1.20:8080/file/3F62E/4AgGT/test.zip"
url = "$file_server_url/file/$uploadid/$fileid/$filename"
url = "$file_server_url/file/$uploadid/$fileid/$dataname"
return Dict("status" => http_response.status, "uploadid" => uploadid, "fileid" => fileid, "url" => url)
end