readFileChunk(file)

Takes a File object argument and returns a readable stream

Arguments
Type
Description
Required

file

File Object

Your input file object

Yes

Returns : ReadableStream

Look inside crypto-middleware

 * @param {File} file - The file from which to read.
 * @returns {ReadableStream} A readable stream from which chunks of data can be read.
 *
 * @example
 * const file = new File(["foo"], "foo.txt", {
 *   type: "text/plain",
 * });
 * const stream = await readFileChunk(file);
 * const reader = stream.getReader();
 * const { value, done } = await reader.read();
 * console.log(value); // Logs the first chunk of data from the file.
 * This is the first part of the startStreaming pipeline 
 */

async function readFileChunk(file) {
    return file.stream()
}

Last updated