From b53b5d25224baa2c5b4e8267b08a8f3e2100d505 Mon Sep 17 00:00:00 2001 From: "Daniel A. Nagy" Date: Fri, 13 Feb 2015 20:21:49 +0100 Subject: [PATCH] upload tool good for directories and files as well. Should work on OS X, too. --- bzz/bzzup/bzzup.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/bzz/bzzup/bzzup.sh b/bzz/bzzup/bzzup.sh index fd1e03d31a..52d07207e1 100755 --- a/bzz/bzzup/bzzup.sh +++ b/bzz/bzzup/bzzup.sh @@ -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