1.0.1 • Published 2 years ago

f2b64 v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

logo-f2b64

NPM Version Node.js Version

Javascript utility for converting files to base64 to save to database and convert back to save or download file.

Install

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm i f2b64

API

const f2b64 = require("f2b64");

f2b64.convertFile2B64(path)

It can convert any file to base64 to save to database. Keeping these fields in the collection or column.

let result = f2b64.convertFile2B64(path);

let namefile = result.name;
let extension = result.ext;
let mimetype = result.mtype;
let array = result.array;

f2b64.convertB642File(namefile, extension, mimetype, array);

Retrieve the file to burn to disk or send as a client download. Passing the parameters retrieved from the database.

let b642file = f2b64.convertB642File(namefile, extension, mimetype, array);

res.setHeader(b642file.contentDisposition, b642file.attachment);
res.type(b642file.type);
res.send(b642file.body); // send download client

License

MIT