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