Uploaded File¶
Import: import system.webapi;
For behavior and native target requirements, see Native Web APIs.
UploadedFile¶
One file part of a multipart/form-data request, bound by @file or returned by HttpIncoming.form. The contents stay in memory up to 1 MiB and then move to a temporary file, so large uploads do not fill memory. The file is deleted when it is closed, when this object is released, or when the request finishes, whichever comes first.
filename¶
Original filename reported by the client.
content_type¶
Media type the client reported for this part; empty when none was sent.
headers¶
Headers sent with this part, such as Content-Disposition.
size¶
Size of the uploaded contents in bytes.
read¶
Reads up to size bytes from the current position; a negative size reads the rest of the file. An empty result means the end of the file. Fails with ECLOSED after close or once the request has finished.
public fun read(
size: int = -1,
token: Option<CancellationToken> = Option.None
): Future<Result<byte[], IoError>>
seek¶
Moves the read position to offset bytes from the start of the file.
public fun seek(
offset: long,
token: Option<CancellationToken> = Option.None
): Future<Result<Unit, IoError>>
close¶
Deletes the stored contents now; later reads fail with ECLOSED. Safe to call repeatedly.
read_async¶
Reads up to max_bytes from the current position; an empty result for a positive request is the end of the file.