summaryrefslogtreecommitdiff
path: root/data_handler
diff options
context:
space:
mode:
Diffstat (limited to 'data_handler')
-rwxr-xr-xdata_handler17
1 files changed, 17 insertions, 0 deletions
diff --git a/data_handler b/data_handler
new file mode 100755
index 0000000..b3936be
--- /dev/null
+++ b/data_handler
@@ -0,0 +1,17 @@
+#!/bin/sh
+hash="$(printf "$1" | sha256sum | cut '-d ' -f1)"
+mime_data="$(printf "%s\n" "$1" | cut -d, -f1)"
+data="$(printf "%s\n" "$1" | cut -d, -f2-)"
+#echo $mime_data
+is_base64="$(printf "%s\n" "$mime_data" | tr ';' '\n' | grep '^base64$')"
+media_type="$(printf "%s\n" "$mime_data" | tr ';' '\n' | head -n1)"
+### what are we going to do with this file?
+mkdir -p ~/.local/var/cache/data
+printf "%s\n" "$data" \
+ | if [ "$is_base64" ];then
+ base64 -d
+ else
+ uriunescape
+ fi \
+ > ~/.local/var/cache/data/$hash
+uristart "file:///home/epoch/.local/var/cache/data/$hash?mime-type=$media_type"