From 3ee0a02e355aa40fe10f464f5101ed5885571894 Mon Sep 17 00:00:00 2001 From: everconnectcn <65219075+everconnectcn@users.noreply.github.com> Date: Sat, 27 Jun 2020 12:49:33 +0800 Subject: [PATCH 1/4] docs: fix a README error --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 960cdeb..6a78d34 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If anything goes wrong, you can rerun the command to resume upload from where it # jq sudo apt install jq -y -curl -sSLo ~/tusc curl https://github.com/adhocore/tusc.sh/releases/latest/download/tusc +curl -sSLo ~/tusc https://github.com/adhocore/tusc.sh/releases/latest/download/tusc # for global binary chmod +x ~/tusc && sudo ln -s ~/tusc /usr/local/bin/tusc # OR, for user binary From be5a88ad5b17c8e1468ff59b32a33cb48e400374 Mon Sep 17 00:00:00 2001 From: Jitendra Adhikari Date: Wed, 7 Oct 2020 22:13:42 +0700 Subject: [PATCH 2/4] feat(tusc): add rest args as curl args --- tusc.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tusc.sh b/tusc.sh index f6c7ff7..39d30f3 100755 --- a/tusc.sh +++ b/tusc.sh @@ -10,7 +10,7 @@ if [[ -f ~/.tus.dbg ]]; then set -ex; else set -e; fi -FULL=$(readlink -f $0) TUSC=$(basename $0) SPINID=0 +FULL=$(readlink -f $0) TUSC=$(basename $0) SPINID=0 CURLARGS= declare -A HEADERS # assoc headers of last request declare ISOK=0 # is last request ok? @@ -107,7 +107,7 @@ request() echo > $HEADER [[ $CREDS ]] && USERPASS="--basic --user '$USER:$PASS' " [[ $DEBUG ]] && comment "> curl ${USERPASS//:$PASS/}-sSLD $HEADER -H 'Tus-Resumable: 1.0.0' $1" - BODY=$(bash -c "curl $USERPASS-sSLD $HEADER -H 'Tus-Resumable: 1.0.0' $1") HEADERS=() + BODY=$(bash -c "curl $USERPASS-sSLD $HEADER -H 'Tus-Resumable: 1.0.0' $CURLARGS $1") HEADERS=() while IFS=':' read key value; do if [[ "${key:0:5}" == "HTTP/" ]]; then @@ -178,6 +178,7 @@ while [[ $# -gt 0 ]]; do -S | --no-spin) NOSPIN=1; shift ;; -u | --update) update; exit 0 ;; --version | version) version; exit 0 ;; + --) shift; CURLARGS=$@; break ;; *) if [[ $HOST ]]; then if [[ $FILE ]]; then SUMALGO="${SUMALGO:-$1}"; else FILE="$1"; fi else HOST=$1; fi From 1e33f1dfde84d53f97e786faa8a410b628164941 Mon Sep 17 00:00:00 2001 From: Jitendra Adhikari Date: Wed, 7 Oct 2020 22:15:05 +0700 Subject: [PATCH 3/4] docs: about -- curl args --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6a78d34..2372f8c 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,8 @@ chmod +x ~/tusc && mv ~/tusc ~/.local/bin/tusc tusc is bash implementation of tus-client (https://tus.io). Usage: - tusc <--options> - tusc [algo] + tusc <--options> -- [curl args] + tusc [algo] -- [curl args] Options: -a --algo The algorigthm for key &/or checksum. @@ -70,8 +70,8 @@ chmod +x ~/tusc && mv ~/tusc ~/.local/bin/tusc tusc --version # prints current version of itself tusc 0:1080 ww.mp4 # uploads ww.mp4 to http://0.0.0.0:1080/files/ tusc -H 0:1080 -f ww.mp4 # same as above + tusc -H 0:1080 -f ww.mp4 -- -Lv # same as above plus sends -Lv to curl command tusc -H 0:1080 -f ww.mp4 -a sha256 # same as above but uses sha256 algo for key/checksum - tusc -H 0:1080 -f ww.mp4 -b /store/ # uploads ww.mp4 to http://0.0.0.0:1080/store/ ``` If you want to parse the output of `tusc`, pass in `-C` (no color) and `-S` (no spin) flags. Eg: @@ -80,6 +80,15 @@ If you want to parse the output of `tusc`, pass in `-C` (no color) and `-S` (no wget $(tusc -H 0:1080 -f ww.mp4 -L -S -C | cut -c 6-999) -O ww.mp4.1 ``` +### Authentication + +If your tusd server requires special header or token for auth, just pass in `[curl args]`: +```sh +tusc -H 0:1080 -f ww.mp4 -b /store/ -- -H 'Authorization: Bearer ' +``` + +In fact you can pass in anything after `--` as extra curl parameter. + ### Preview See `tusc` in action with debug mode where the upload is aborted frequently with `Ctrl+C` interrupt. From 9b7160f932c0491fe01368e149a183b65ad995d9 Mon Sep 17 00:00:00 2001 From: Jitendra Adhikari Date: Wed, 7 Oct 2020 22:15:45 +0700 Subject: [PATCH 4/4] build(travis): test curl args --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b6e19ad..5d0a3d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ script: # upload - './tusd_linux_amd64/tusd --upload-dir ~/.tusd-data --base-path /tus/ > /dev/null 2>&1 &' - - './tusc.sh -H 0:1080 -f tusd_linux_amd64.tar.gz -a sha256 -b /tus/' + - './tusc.sh -H 0:1080 -f tusd_linux_amd64.tar.gz -a sha256 -b /tus/ -- -v' # download and verify - 'URL=$(./tusc.sh -H 0:1080 -f tusd_linux_amd64.tar.gz -a sha256 -b /tus/ -L -C -S | cut -c 6-999)'