You are not logged in.
I thought this was a neat command. I wouldnt recommend using it on a large file though, will output massive amounts of characters on your terminal. Small text files seem to be ok.
Ive used this for my resume and then shortened the 4000 plus character uri with bit.ly.
You can do something like $ dataurl myfile > myfile.txt if you dont want to output to screen.
# Create a data URL from a file
function dataurl() {
local mimeType=$(file -b --mime-type "$1");
if [[ $mimeType == text/* ]]; then
mimeType="${mimeType};charset=utf-8";
fi
echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')"
Last edited by clusterF (2019-09-12 10:58:24)
Offline