Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
if [ -z "$1" ]; then
echo "usage: data-url file" >&2
exit 1
mimetype=$(file -bN --mime-type "$1")
content=$(base64 < "$1")
echo "data:$mimetype;base64,$content"

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment