UNPKG

@adonis-agora/media

Version:

Media-library for AdonisJS — owner collections (MIME whitelist, single-file replace, ordering), image conversions (eager/lazy), pluggable content transformers (HLS video via mediabunny, metadata probe, image blur-up placeholder), and column attachments, a

35 lines • 1.89 kB
import { Readable } from 'node:stream'; /** * Coerce attach/create inputs (a `Buffer` or a `Readable`) to a `Uint8Array` for the disk's `put`, * which (matching flydrive) does not accept a stream. A `Buffer` is already a `Uint8Array`. */ export declare function toBytes(contents: Buffer | Readable): Promise<Uint8Array>; /** Read back disk bytes as a Node `Buffer` for the image processor (which works on Buffers). */ export declare function asBuffer(bytes: Uint8Array): Buffer; /** What {@link peekContents} hands back: the sniffed head, plus contents still safe to write. */ export interface PeekedContents { /** Up to `length` leading bytes (fewer if the payload is shorter). */ head: Uint8Array; /** * The contents to write. Identical to the input for a `Buffer`; for a `Readable` it is a NEW * stream that replays the consumed head before the untouched remainder, so the peek is invisible * downstream. */ contents: Buffer | Readable; } /** * Read the first `length` bytes of an attach payload WITHOUT consuming it, so the caller can sniff * its real content type and still write every byte. * * A `Readable` cannot be rewound, so the head is re-emitted in front of the rest through a fresh * stream driven by the SAME async iterator — no buffering of the full payload, which is what keeps * the streaming attach path (large uploads, no conversions) streaming. */ export declare function peekContents(contents: Buffer | Readable, length: number): Promise<PeekedContents>; /** * Read the first `length` bytes of an object already on a disk and stop — the stream is destroyed * as soon as enough bytes are in hand, so adopting a 2 GiB scan in place costs one short ranged * read rather than a download. */ export declare function peekStream(stream: Readable, length: number): Promise<Uint8Array>; //# sourceMappingURL=contents.d.ts.map