This documentation provides the usage of @filego/ts
.
Install @filego/ts
as a dependency:
# NPM
npm install @filego/ts
# Yarn
yarn add @filego/ts
# PNPM
pnpm add @filego/ts
@filego/ts
provides the following functions:
This function splits file into chunks, and the chunks can be used to check and merge later. It will return the chunks
, fileSize
and totalChunks
.
import { split } from "@filego/ts";
const file: File | Blob | Uint8Array | string = "";
await split({
file,
chunkSize: 2 * 1024 * 1024,
});
This function checks file integrity by verifying the chunks
with fileSize
and totalChunks
parameters. It will return the status
and the error
of the check.
import { check } from "@filego/ts";
await check({
chunks: [], // result from split function...
fileSize: 0, // result from split function...
totalChunks: 0, // result from split function...
});
This function merges the chunks by using the chunks
parameters. It will return the blob
and buffer
of the merged file.
import { merge } from "@filego/ts";
await merge({
chunks: [], // result from split function...
});