IHttpFile: AsyncIterable<Uint8Array> & {
    contentType: string;
    fileSize: FileSize;
    lastModified: Date;
    name: string;
    asArrayBuffer(): Promise<ArrayBuffer>;
    asBytes(): Promise<Uint8Array<ArrayBufferLike>>;
    asFile(): File;
    asReadableStream(): ReadableStream<Uint8Array<ArrayBufferLike>>;
    asText(): Promise<string>;
}

Represents a file that was uploaded as part of an HTTP request (typically via multipart/form-data). Provides multiple methods to access the file's content in various formats — text, binary, ArrayBuffer, or as a stream for efficient handling of large files.

IMPORT_PATH: "@daiso-tech/core/http-router/contracts"

Type declaration

  • ReadonlycontentType: string

    The MIME content type of the file (e.g. "image/png").

  • ReadonlyfileSize: FileSize

    Returns the size of the file in bytes as a FileSize.

    The file size.

  • ReadonlylastModified: Date

    The last modified timestamp of the file.

  • Readonlyname: string

    The original file name from the upload.

  • asArrayBuffer:function
  • asBytes:function
    • Reads the file content as a Uint8Array (raw binary data).

      Returns Promise<Uint8Array<ArrayBufferLike>>

      A promise that resolves with the file content as bytes.

  • asFile:function
  • asReadableStream:function
    • Reads the file content as a ReadableStream<Uint8Array> using the Web Streams API. Suitable for streaming large files without loading the entire content into memory.

      Returns ReadableStream<Uint8Array<ArrayBufferLike>>

      A promise that resolves with a readable stream of the file content.

  • asText:function