Skip to content

basalt / http/src / UploadedFile

Interface: UploadedFile ​

Defined in: http/src/upload.ts:30

One uploaded file, handed to the handler while its bytes are still arriving.

Properties ​

declaredLength? ​

> optional declaredLength?: number

Defined in: http/src/upload.ts:52

The size the client declared for THIS part (its own Content-Length header), when it sent one. RFC 7578 does not require it and browsers never send it, so it is usually undefined — there is no honest way to derive a per-file size from the request's Content-Length, which covers every part plus the multipart framing. Pass it straight to a backend that wants an exact size (files.upload(file.stream, { contentLength })); the real size is still measured from the bytes that arrive.


declaredType ​

> declaredType: string

Defined in: http/src/upload.ts:36

The part's declared Content-Type essence (default application/octet-stream). Client-controlled.


field ​

> field: string

Defined in: http/src/upload.ts:32

The form field the file was sent under.


filename ​

> filename: string

Defined in: http/src/upload.ts:34

Sanitised basename (no directories, controls or bidi tricks) — a label, never a storage key.


stream ​

> stream: Readable

Defined in: http/src/upload.ts:42

The file's bytes, streamed. Consume it (or destroy() it) before asking for the next file; a file left unread is skipped when the next one is requested. It errors with the limit's HttpError if the upload breaks one.

Released under the MIT License.