File upload
Send a File directly. This browser snippet creates a small synthetic file for this site’s demo API.
import { Http, bare, ContentType } from "fetchzen";const api = Http.create(`${location.origin}/api/examples/`, { cache: false, secure: false, preset: bare,});const file = new File(["Hello"], "demo.txt", { type: "text/plain" });console.log(await api.post("upload/", file, { type: ContentType.APPLICATION_OCTET_STREAM,}));Ready. No request sent.
Fetch does not report upload progress. Wait for the server's receipt to confirm the file arrived.
Result
Choose Run to see the response.
Event log
No events yet.
What to notice
Section titled “What to notice”The demo accepts up to 1 MiB, counts bytes and discards them without storage. Browser Fetch has no upload progress callbacks: waiting stays indeterminate until the receipt. Use your own upload endpoint in an application.
For opt-in server-confirmed progress, use a cooperating chunk endpoint, not this whole-file endpoint.
Next: multipart or file transfers.