Created
November 8, 2021 14:50
-
-
Save mathieu-aubin/c378f4fb59d73cc41c26e3c849834080 to your computer and use it in GitHub Desktop.
base64 web data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ ! -e "${1}" ]; then | |
echo "File not found"; | |
echo "Usage: $(basename "${0}") input_file"; | |
else | |
type=$(file --mime-type --brief "${1}"); | |
w="$(echo $type|cut -d/ -f2)"; | |
raw=$(cat "${1}" | base64 -iw0 | sed 's| ||g'); | |
tmpf=$(mktemp); | |
echo -e "---- ${w^^}64 OUTPUT FOR: ${1} ----\n\ndata:${type};base64,${raw}\n\n---- END ${w^^}64 OUTPUT FOR: ${1} ----" > $tmpf; | |
cat $tmpf; | |
echo "data:${type};base64,"$raw | sed 's|\n||g' | sed 's| ||g' > $tmpf; | |
echo -e "\nURL READY OUTPUT SAVED TO: $tmpf"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment