Skip to content

Home > robinson > getFileChunk

getFileChunk() function

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

生成文件切片数组

Signature:

typescript
declare function getFileChunk(file: File, chunkSize?: number): Array<{
    index: number;
    file: Blob;
}>;
declare function getFileChunk(file: File, chunkSize?: number): Array<{
    index: number;
    file: Blob;
}>;

Parameters

ParameterTypeDescription
fileFile文件对象
chunkSizenumber(Optional) 每个切片的大小(字节),默认为1MB

Returns:

Array<{ index: number; file: Blob; }>

切片数组,每个元素包含索引和Blob对象

Example

getFileChunk(fileInput.files[0], 1024 * 1024).forEach(chunk => console.log(chunk));

Released under the MIT License.