fake-file-url

1.0.1 • Public • Published

Fake File URL

This package transforms your base64 content file in a fake url to use in frontend url tags.

import { createBlob } from 'fake-file-url';

// Sometimes you will only have the base64 content of the file,
// from API or file in the frontend, so to make it possible to download it
// you can use fake-file-url to generate a downloadable url from it
const pdfFileContentInBase64 = '...';
// fakeUrl will have a temporary URL that you can put inside a <a> tag
// so the users can download the content of the file.
const fakeUrl = createBlob(pdfFileContentInBase64, 'application/pdf');

// ...

return <a href={fakeURL} download>Download PDF file</a>;

Package Sidebar

Install

npm i fake-file-url

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

4.11 kB

Total Files

5

Last publish

Collaborators

  • lucasfloriani