Skip to content

Instantly share code, notes, and snippets.

@frenzzy
Created May 20, 2022 09:53
Show Gist options
  • Save frenzzy/0c5797391cb663229e78712e4063b5cf to your computer and use it in GitHub Desktop.
Save frenzzy/0c5797391cb663229e78712e4063b5cf to your computer and use it in GitHub Desktop.
Any file to base64 url cli tool
var path = require('path');
var fs = require('fs');
var mime = 'application/octet-stream';
var encoding = 'base64';
var data = fs.readFileSync(path.resolve(process.argv[process.argv.length - 2])).toString(encoding);
var uri = 'data:' + mime + ';' + encoding + ',' + data;
fs.writeFileSync(path.resolve(process.argv[process.argv.length - 1]), uri)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment