@binary-files/web-file-mover

function to download an ArrayBuffer as a file

Usage no npm install needed!

<script type="module">
  import binaryFilesWebFileMover from 'https://cdn.skypack.dev/@binary-files/web-file-mover';
</script>

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 users device.

Get File from Server

getFileFromServer(url: string): Promise<ArrayBuffer>

Calling this funciton 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.