This is a client for https://cowtransfer.cn.
Most code is from https://github.com/Mikubill/cowtransfer-uploader. I have
removed dependency on github.com/cheggaaa/pb
in favor of various progress
event hooks. The intention is to decouple the CLI from the library API.
Download the file you want to your remote machine:
curl -Lo myfile.dat "http://www.example.com/myfile.dat"
Cowtransfer offers a password protection feature, but why trust 'em when you can encrypt locally? Of course, this step is optional.
openssl enc -aes-256-cbc -in ./myfile.dat -out myfilec.dat
Sometimes cowtransfer have problems with large files. If that happens, chop things up to smaller bits! The command below will create myfilec.aa, myfilec.ab, ..., each file being 512mb.
split --verbose -b 512M myfilec.dat myfilec.dat.
ls -lh myfilec.dat.*
Install the latest version of cowtransfer CLI client. Example for Linux shown below:
latest_ver=$(curl -fsSL "https://api.github.com/repos/imacks/cowtransfer/releases/latest" | grep tag_name | cut -d'"' -f4)
curl -Lo cowput "https://github.com/imacks/cowtransfer/releases/download/${latest_ver}/cowput_linux"
chmod +x cowput
./cowput -h
Time to upload:
files=$(ls -1 myfilec.dat.*)
./cowput $files
Lots of progress messages follows, but look out for the final download link. Here's an example:
link: https://cowtransfer.com/s/abab0000123456
Now you can use your local computer to visit the URL. You may simply choose to download what you want from the browser, but if there are a lot of files, read on to automate the download process too.
You need to install cowtransfer CLI client on your local computer first. If your local PC is Linux too, installation steps are identical as for remote machine. I will show an example for Windows below:
$latestver = wget -UseBasicParsing "https://api.github.com/repos/imacks/cowtransfer/releases/latest" | select -expand Content | ConvertFrom-Json | select -expand tag_name
wget -OutFile cowtransfer.exe "https://github.com/imacks/cowtransfer/releases/download/${latestver}/cowput.exe"
cowput -h
You need the download link for the next step:
cowput https://cowtransfer.com/s/abab0000123456
This will get the actual direct download URLs for all the files. Download them using your favorite download tool.
On Windows, use the awesome 7-zip to open any of the downloaded files. 7-zip can handle decryption and split files.
A bit more work is necessary if using Linux:
To join split files:
cat myfilec.dat.* > myfilec.dat
To decrypt your file:
openssl enc -aes-256-cbc -d -in myfilec.dat > myfile.dat
You may want to clear up your remote machine to save some disk space:
rm myfile.dat myfilec.dat myfilec.dat.*