1st commit
This commit is contained in:
42
etc.jl
Normal file
42
etc.jl
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
""" fileServerURL = "http://192.168.88.104:8080"
|
||||
filepath = "/home/ton/docker-apps/sendreceive/image/test.zip"
|
||||
filename = basename(filepath)
|
||||
filebytes = read(filepath)
|
||||
|
||||
plik_oneshot_upload - Upload a single file to a plik server using one-shot mode
|
||||
|
||||
This function uploads a raw byte array to a plik server in one-shot mode (no upload session).
|
||||
It first creates a one-shot upload session by sending a POST request with `{"OneShot": true}`,
|
||||
retrieves an upload ID and token, then uploads the file data as multipart form data using the token.
|
||||
|
||||
The function handles the entire flow:
|
||||
1. Obtains an upload ID and token from the server
|
||||
2. Uploads the provided binary data as a file using the `X-UploadToken` header
|
||||
3. Returns identifiers and download URL for the uploaded file
|
||||
|
||||
# Arguments:
|
||||
- `fileServerURL::String` - Base URL of the plik server (e.g., `"http://192.168.88.104:8080"`)
|
||||
- `filename::String` - Name of the file being uploaded
|
||||
- `data::Vector{UInt8}` - Raw byte data of the file content
|
||||
|
||||
# Return:
|
||||
- A named tuple with fields:
|
||||
- `uploadid::String` - ID of the one-shot upload session
|
||||
- `fileid::String` - ID of the uploaded file within the session
|
||||
- `downloadurl::String` - Full URL to download the uploaded file
|
||||
|
||||
# Example
|
||||
```jldoctest
|
||||
using HTTP, JSON
|
||||
|
||||
# Example data: "Hello" as bytes
|
||||
data = collect("Hello World!" |> collect |> CodeUnits |> collect)
|
||||
|
||||
# Upload to local plik server
|
||||
result = plik_oneshot_upload("http://192.168.88.104:8080", "hello.txt", data)
|
||||
|
||||
# Download URL for the uploaded file
|
||||
println(result.downloadurl)
|
||||
```
|
||||
"""
|
||||
Reference in New Issue
Block a user