0.4.0 • Published 4 years ago

@perseu/browser-file-downloader v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Browser File Downloader

A simple JavaScript module for download file from a Blob in the Browser-side.

Installing

NPM:

npm install @perseu/browser-file-downloader

Yarn:

yarn add @perseu/browser-file-downloader

Example

import FileDownloader from '@perseu/browser-file-downloader'

await FileDownloader.downloadFileAsPdf(blob, fileName)

API

Methods

downloadFileAsPdf(data, fileName)

  • data: File|ArrayBuffer|Blob the data object to be downloaded.
  • fileName: ?String the name of the file that will be downloaded. The file extension type should to be explicit (e.g. Download.pdf). The default value is Download.
  • returns: Promise<void>

    This method will download the data as a PDF file.

downloadFileAs(data, type, fileName)

  • data: File|ArrayBuffer|Blob the data object to be downloaded.
  • type: ?String the MIME type of the file. The default value is text/plain.
  • fileName: ?String the name of the file that will be downloaded. The file extension type should to be explicit (e.g. Download.pdf). The default value is Download.
  • returns: Promise<void>

    This method will download the data as specified in type parameter.

downloadFile(blob, fileName)

  • blob: Blob the blob object to be downloaded.
  • fileName: String the name of the file that will be downloaded. The file extension type should to be explicit (e.g. Download.pdf).
  • returns: void

    This method will download the blob as a file. The file type should be informed on the Blob object.

base64ToArrayBuffer(base64)

  • base64: String the base64 string to be converted.
  • returns: ArrayBuffer

    This method will convert the base64 string to a ArrayBuffer object.

License

MIT

0.4.0

4 years ago

0.3.0

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago

0.0.0

4 years ago