Very simple directory upload tool

This commit is contained in:
Daniel A. Nagy 2015-02-13 17:27:24 +01:00
parent 6baa73c24e
commit 74e8f1c3ea

28
bzz/bzzup/bzzup.sh Executable file
View file

@ -0,0 +1,28 @@
#! /bin/bash
INDEX='index.html'
bzzroot="$1"
[ "_$1" = _ ] && bzzroot=.
delimiter='[{'
pushd "$bzzroot" > /dev/null
(for path in `find . -type f`
do
name=`echo "$path" | cut -c2-`
[ _`basename "$name"` = "_$INDEX" ] && name=`dirname "$name"`
echo -n "$delimiter"
hash=`wget -q -O- --post-file="$path" http://localhost:8500/raw`
mime=`mimetype -b "$path"`
echo -n "\"hash\":\"$hash\",\"path\":\"$name\",\"content_type\":\"$mime\""
delimiter='},{'
done
echo -n '}]') | wget -q -O- --post-data=`cat` http://localhost:8500/raw
echo
popd > /dev/null