Upload examples

Basic CLI upload

curl \ -F 'files=@./photo.png' \ -F 'retention=24h' \ {{ origin }}/upload

Multiple files with password

curl \ -F 'files=@./one.png' \ -F 'files=@./two.zip' \ -F 'retention=1h' \ -F 'password=secret-pass' \ {{ origin }}/upload

Go

package main import ( "bytes" "fmt" "io" "mime/multipart" "net/http" "os" ) func main() { file, err := os.Open("photo.png") if err != nil { panic(err) } defer file.Close() var body bytes.Buffer writer := multipart.NewWriter(&body) part, err := writer.CreateFormFile("files", "photo.png") if err != nil { panic(err) } if _, err := io.Copy(part, file); err != nil { panic(err) } _ = writer.WriteField("retention", "1h") writer.Close() req, err := http.NewRequest("POST", "{{ origin }}/upload", &body) if err != nil { panic(err) } req.Header.Set("Content-Type", writer.FormDataContentType()) resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close() out, _ := io.ReadAll(resp.Body) fmt.Println(string(out)) }

Java 11+ HttpClient

import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.nio.file.Files; import java.nio.file.Path; public class UploadWarpBox { public static void main(String[] args) throws Exception { String boundary = "----WarpBoxBoundary" + System.currentTimeMillis(); Path file = Path.of("photo.png"); byte[] prefix = ("--" + boundary + "\r\n" + "Content-Disposition: form-data; name=\"retention\"\r\n\r\n" + "1h\r\n" + "--" + boundary + "\r\n" + "Content-Disposition: form-data; name=\"files\"; filename=\"photo.png\"\r\n" + "Content-Type: application/octet-stream\r\n\r\n").getBytes(); byte[] suffix = ("\r\n--" + boundary + "--\r\n").getBytes(); byte[] fileBytes = Files.readAllBytes(file); byte[] body = new byte[prefix.length + fileBytes.length + suffix.length]; System.arraycopy(prefix, 0, body, 0, prefix.length); System.arraycopy(fileBytes, 0, body, prefix.length, fileBytes.length); System.arraycopy(suffix, 0, body, prefix.length + fileBytes.length, suffix.length); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("{{ origin }}/upload")) .header("Content-Type", "multipart/form-data; boundary=" + boundary) .POST(HttpRequest.BodyPublishers.ofByteArray(body)) .build(); HttpResponse<String> response = HttpClient.newHttpClient() .send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } }

JavaScript Node.js

import { openAsBlob } from 'node:fs'; const file = await openAsBlob('./photo.png'); const form = new FormData(); form.append('files', file, 'photo.png'); form.append('retention', '1h'); const res = await fetch('{{ origin }}/upload', { method: 'POST', body: form }); console.log(await res.text());