uploader with progress bar. reown log file

This commit is contained in:
2018-09-14 17:08:00 +03:00
parent b29f3790c1
commit 1fe84e3f72
3 changed files with 41 additions and 17 deletions

View File

@@ -3,18 +3,15 @@ test -n "$1" || {
echo "Add files to upload as argument"
exit 1
}
CAT=$( which cat )
which pv &> /dev/null && CAT=$( which pv )
ROOTURL="{{ rooturl }}"
SHARE="{{ name }}"
TOKEN="{{ token }}"
send_file() {
$CAT "$file_name" | curl -F "file=@-;filename=${base_name}" "${ROOTURL}upload/${SHARE}/${TOKEN}"
cat "$file_name" | curl --progress-bar -F "file=@-;filename=${base_name}" "${ROOTURL}upload/${SHARE}/${TOKEN}" | cat -
}
send_folder() {
which pv &> /dev/null && printf -v dusize -- "--size %dk" $( du -s -k "$file_name" | cut -f1 )
tar cz "$file_name" | $CAT $dusize - | curl -F "file=@-;filename=${base_name}.tgz" ${ROOTURL}upload/${SHARE}/${TOKEN}
tar cz "$file_name" | curl --progress-bar -F "file=@-;filename=${base_name}.tgz" "${ROOTURL}upload/${SHARE}/${TOKEN}" | cat -
}
for file_name in "$@"; do