@adonisjs/bodyparser
Version:
BodyParser middleware for AdonisJS http server to read and parse request body
18 lines (17 loc) • 651 B
TypeScript
import { type Readable } from 'node:stream';
/**
* Streams a file from a readable stream to a file system location. Automatically
* cleans up on errors and optionally reports data chunks to a listener.
*
* @param readStream - The source readable stream
* @param location - The destination file path
* @param dataListener - Optional callback to receive data chunks
*
* @example
* ```ts
* await streamFile(part, '/tmp/upload.jpg', (chunk) => {
* console.log('Received', chunk.length, 'bytes')
* })
* ```
*/
export declare function streamFile(readStream: Readable, location: string, dataListener?: (line: Buffer) => void): Promise<void>;