loading...

Resumable file upload (TUS protocol implementation) using pure bash

adhocore profile image Jitendra Adhikari ・1 min read

Introducing tusc.sh - bash script for resumable file upload using tus protocol.

GitHub logo adhocore / tusc.sh

TUS client protocol implementation for bash.

adhocore/tusc.sh

Latest Version Travis Build Software License

tusc is TUS client protocol implementation for bash.

tusc lets you upload big files to servers supporting tus protocol right from your terminal.

If anything goes wrong, you can rerun the command to resume upload from where it was left off.

Installation

# Requirements:
# jq
sudo apt install jq -y
curl -sSLo ~/tusc https://raw.githubusercontent.com/adhocore/tusc.sh/master/tusc.sh
chmod +x ~/tusc && sudo ln -s ~/tusc /usr/local/bin/tusc

Usage and Examples

  tusc v0.0.1 | (c) Jitendra Adhikari
  tusc is bash implementation of tus-client (https://tus.io)
  Usage
    tusc <--options>
    tusc <host> <file> [algo]
  Options:
    -a --algo      The algorigthm for key &/or checksum.
                   (Eg: sha1, sha256)
    -f --file      The file to upload.
    -h --help      Show help information and usage.
    -H --host      The tus-server host where file is uploaded.
  Examples:
    tusc version                 # prints current version of itself
    tusc --help                  # shows this help
    tusc 0:1080 ww.mp4           # uploads ww.mp4 to http://0.0.0.0:1080
    tusc -f

Installation

sudo apt install jq -y

curl -sSLo ~/tusc https://raw.githubusercontent.com/adhocore/tusc.sh/master/tusc.sh
chmod +x ~/tusc && sudo ln -s ~/tusc /usr/local/bin/tusc

Getting Started

To get hands on locally, you can install tusd server.

Then,

# run tusd server (http://0.0.0.0:1080)
tusd -dir ~/.tusd-data &

# start uploading large files
DEBUG=1 tusc --host 0:1080 --file /full/path/to/large/file

While upload is in progress, you can force abort it using Ctrl+C

Then resume upload again:

DEBUG=1 tusc --host 0:1080 --file /full/path/to/large/file

It should start from where it last stopped.

You can check the uploaded files like so:

ls -al ~/.tusd-data

Feedback and suggestions are welcome and highly appreciated.

Thanks :)

Discussion

pic
Editor guide