upload tool good for directories and files as well. Should work on OS X, too.

This commit is contained in:
Daniel A. Nagy 2015-02-13 20:21:49 +01:00
parent b596f34056
commit b53b5d2522

View file

@ -2,11 +2,21 @@
INDEX='index.html'
delimiter='{"entries":[{'
if [ -f "$1" ]; then
hash=`wget -q -O- --post-file="$1" http://localhost:8500/raw`
mime=`file --mime-type -b "$1"`
wget -q -O- --post-data="$delimiter\"hash\":\"$hash\",\"contentType\":\"$mime\"}]}" http://localhost:8500/raw
echo
else
[ -d "$1" ] || exit -1
bzzroot="$1"
[ "_$1" = _ ] && bzzroot=.
delimiter='{"entries":[{'
pushd "$bzzroot" > /dev/null
(for path in `find . -type f`
@ -15,14 +25,14 @@ 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"`
mime=`file --mime-type -b "$path"`
echo -n "\"hash\":\"$hash\",\"path\":\"$name\",\"contentType\":\"$mime\""
delimiter='},{'
done
echo -n '}]}') | wget -q -O- --post-data=`cat` http://localhost:8500/raw
echo
popd > /dev/null
fi