@binary-files/web-file-mover
v1.3.0
Published
Helper methods for moving and working with Files and ArrayBuffers
Downloads
4
Readme
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
.