Easy file sharing from the command line

# Upload using cURL
$ curl --upload-file ./hello.txt https://d.chaifeng.com/hello.txt https://d.chaifeng.com/66nb8/hello.txt

# Using the alias
$ transfer hello.txt
###################################s################## 100.0% https://d.chaifeng.com/eibhM/hello.txt

# Upload from web
Drag your files here, or click to browse.

# Download all your files

zip tar.gz

Sample use cases

How to upload

# Uploading is easy using curl
$ curl --upload-file ./hello.txt https://d.chaifeng.com/hello.txt
https://d.chaifeng.com/66nb8/hello.txt
# Download the file
$ curl https://d.chaifeng.com/66nb8/hello.txt -o hello.txt

Add an alias to .bashrc or .zshrc [gist]

# Add this to .bashrc or its equivalent
transfer() { if [ $# -eq 0 ]; then echo "No arguments specified. Usage:\necho transfer /tmp/test.md [more files]\ncat /tmp/test.md | transfer test.md"; return 1; fi; tmpfile="$( mktemp -t transferXXX )"; query="$1"; [[ -z "$query" ]] && exit 1; CURL_OPTS=(--progress-bar --upload-file); if ! tty -s; then curl "${CURL_OPTS[@]}" "-" "https://d.chaifeng.com/$query" >> "$tmpfile" ; elif [[ $# > 1 ]] || [[ -d "$query" ]]; then [[ $# > 1 ]] && query="archive-$(date +%Y%m%d%H%M%S)"; zip -q -r - "$@" | curl "${CURL_OPTS[@]}" "-" "https://d.chaifeng.com/${query}.zip" >> $tmpfile ; elif [[ -f "$query" ]]; then curl "${CURL_OPTS[@]}" "$query" "https://d.chaifeng.com/" >> "$tmpfile"; else echo "Error: '$query' not found."; exit 2; fi; cat $tmpfile; rm -f $tmpfile; }

# Now you can use transfer command
$ transfer hello.txt
More examples

Upload multiple files at once


$ curl -i -F filedata=@/tmp/hello.txt -F filedata=@/tmp/hello2.txt https://d.chaifeng.com/

# Combining downloads as zip or tar archive
$ curl https://d.chaifeng.com/(15HKz/hello.txt,15HKz/hello.txt).tar.gz
$ curl https://d.chaifeng.com/(15HKz/hello.txt,15HKz/hello.txt).zip

Encrypt your files before the transfer

# Encrypt files with password using gpg
$ cat /tmp/hello.txt|gpg -ac -o-|curl -X PUT --upload-file "-" https://d.chaifeng.com/test.txt

# Download and decrypt
$ curl https://d.chaifeng.com/1lDau/test.txt|gpg -o- > /tmp/hello.txt

Scan for malware

# Scan for malware or viruses using Clamav
$ wget http://www.eicar.org/download/eicar.com
$ curl -X PUT --upload-file ./eicar.com https://d.chaifeng.com/eicar.com/scan

# Upload malware to VirusTotal, get a permalink in return
$ curl -X PUT --upload-file nhgbhhj https://d.chaifeng.com/test.txt/virustotal

Backup mysql database, encrypt and transfer

# Backup, encrypt and transfer
$ mysqldump --all-databases|gzip|gpg -ac -o-|curl -X PUT --upload-file "-" https://d.chaifeng.com/test.txt

Send email with transfer link (uses alias)

# Transfer and send email with link (uses alias)
$ transfer /tmp/hello.txt | mail -s "Hello World" user@yourmaildomain.com

Using Keybase.io

# Import keys from keybase
$ keybase track [them] # Encrypt for recipient(s)
$ cat somebackupfile.tar.gz | keybase encrypt [them] | curl --upload-file '-' https://d.chaifeng.com/test.txt # Decrypt
$ curl https://d.chaifeng.com/sqUFi/test.md |keybase decrypt

wget uploads also supported

# wget
$ wget --method PUT --body-file=/tmp/file.tar https://d.chaifeng.com/file.tar -O - -nv

Transfer pound logs

# grep syslog for pound and transfer
$ cat /var/log/syslog|grep pound|curl --upload-file - https://d.chaifeng.com/pound.log