@binary-files/web-file-mover
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

Web File Mover

Web file mover is a collection of small helper methods for moving binary files from a server to the web, and from the web to the user's device.

Get File from Server

getFileFromServer(url: string): Promise<ArrayBuffer>

Calling this function with a url string will return a promise that will resolve with an ArrayBuffer of the file fetched.

Save File to Device

saveFileToDevice(arrayBuffer: ArrayBuffer, filename: string, mimeType?: string): void;

Calling this function with an ArrayBuffer and a file name will trigger a download of the file.

Read File into ArrayBuffer

fileToArrayBuffer(file: File): Promise<ArrayBuffer>

Calling this function with a File you will get a promise that will resolve with the file's contents in an ArrayBuffer.

Read Part of File into ArrayBuffer

fileChunkToArrayBuffer(file: File, startOffset: number, chunkSize: number): Promise<ArrayBuffer>

Calling this function with a File, a startOffset and chunkSize will give you an ArrayBuffer containing a piece of the file starting from startOffset with a byte length of chunkSize.

Readme

Keywords

none

Package Sidebar

Install

npm i @binary-files/web-file-mover

Weekly Downloads

2

Version

1.3.0

License

ISC

Unpacked Size

7.99 kB

Total Files

9

Last publish

Collaborators

  • rlouie