Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <host> <file> [algo]
tusc <--options> -- [curl args]
tusc <host> <file> [algo] -- [curl args]

Options:
-a --algo The algorigthm for key &/or checksum.
Expand All @@ -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:
Expand All @@ -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 <token>'
```

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.

Expand Down
5 changes: 3 additions & 2 deletions tusc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down