Files
flees/code/templates/upload.sh

30 lines
702 B
Bash

#!/bin/bash
test -n "$1" || {
echo "Add files to upload as argument"
exit 1
}
ROOTURL="{{ rooturl }}"
SHARE="{{ name }}"
TOKEN="{{ token }}"
send_file() {
cat "$file_name" | curl -fL -F "file=@-;filename=${base_name}" "${ROOTURL}upload/${SHARE}/${TOKEN}" | cat -
}
send_folder() {
tar cz "$file_name" | curl -fL -F "file=@-;filename=${base_name}.tgz" "${ROOTURL}upload/${SHARE}/${TOKEN}" | cat -
}
for file_name in "$@"; do
base_name=$( basename "$file_name" )
test -f "$file_name" && {
printf "Sending file: %s\n" "$file_name"
send_file
continue
}
test -d "$file_name" && {
printf "Sending folder: %s\n" "$file_name"
send_folder
continue
}
done