Skip to main content

CLI Ways to Transfer file Part I

 CLI options:

file.io

Easy to use API

Try it out:

$ curl -F "file=@test.txt" https://file.io
{"success":true,"key":"2ojE41","link":"https://file.io/2ojE41","expiry":"14 days"}
$ curl https://file.io/2ojE41
This is a test
$ curl https://file.io/2ojE41
{"success":false,"error":404,"message":"Not Found"}

Or set an expiration:

$ curl -F "file=@test.txt" https://file.io/?expires=1w
{"success":true,"key":"aQbnDJ","link":"https://file.io/aQbnDJ","expiry":"7 days"}
$ sleep 604801
$ curl https://file.io/aQbnDJ
{"success":false,"error":404,"message":"Not Found"}

The query param expires must be a positive integer which, by default, represents the number of days until the file will be deleted (defaults to 14 days). If you follow it with w, it will be the number of weeks. m for months and y for years.

You can also send direct text to file.io:

$ curl --data "text=this is a secret pw" https://file.io
{"success":true,"key":"pgiPc2","link":"https://file.io/pgiPc2","expiry":"14 days"}
$ curl https://file.io/pgiPc2
this is a secret pw
$ curl https://file.io/pgiPc2
{"success":false,"error":404,"message":"Not Found"}


transfer.sh

Sample use cases

How to upload

# Uploading is easy using curl $ curl --upload-file ./hello.txt https://transfer.sh/hello.txt https://transfer.sh/66nb8/hello.txt $ curl -H "Max-Downloads: 1" -H "Max-Days: 5" --upload-file ./hello.txt https://transfer.sh/hello.txt https://transfer.sh/66nb8/hello.txt # Download the file $ curl https://transfer.sh/66nb8/hello.txt -o hello.txt

Add shell function to .bashrc or .zshrc

# Add this to .bashrc or .zshrc or its equivalent transfer(){ if [ $# -eq 0 ];then echo "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>">&2;return 1;fi;if tty -s;then file="$1";file_name=$(basename "$file");if [ ! -e "$file" ];then echo "$file: No such file or directory">&2;return 1;fi;if [ -d "$file" ];then file_name="$file_name.zip" ,;(cd "$file"&&zip -r -q - .)|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null,;else cat "$file"|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null;fi;else file_name=$1;curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null;fi;} # Now you can use transfer function $ transfer hello.txt

More examples

Upload multiple files at once

$ curl -i -F filedata=@/tmp/hello.txt -F filedata=@/tmp/hello2.txt https://transfer.sh/ # Combining downloads as zip or tar archive $ curl https://transfer.sh/(15HKz/hello.txt,15HKz/hello.txt).tar.gz $ curl https://transfer.sh/(15HKz/hello.txt,15HKz/hello.txt).zip

Encrypt your files with gpg before the transfer

# Encrypt files with password using gpg $ cat /tmp/hello.txt|gpg -ac -o-|curl -X PUT --upload-file "-" https://transfer.sh/test.txt # Download and decrypt $ curl https://transfer.sh/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://transfer.sh/eicar.com/scan # Upload malware to VirusTotal, get a permalink in return $ curl -X PUT --upload-file nhgbhhj https://transfer.sh/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://transfer.sh/test.txt

Send email with transfer link (uses shell function)

# Transfer and send email with link (uses shell function) $ 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://transfer.sh/test.txt # Decrypt $ curl https://transfer.sh/sqUFi/test.md |keybase decrypt

wget uploads also supported

# wget $ wget --method PUT --body-file=/tmp/file.tar https://transfer.sh/file.tar -O - -nv

Transfer pound logs

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

Upload a file using Powershell

# Upload using Powershell PS H:\> invoke-webrequest -method put -infile .\file.txt https://transfer.sh/file.txt

Upload a file using HTTPie

# HTTPie $ http https://transfer.sh/ -vv < /tmp/test.log

Upload a file using Unofficially client in Python

# transfersh-cli (https://github.com/tanrax/transfersh-cli) $ transfersh photos.zip # Uploading file # Download from here: https://transfer.sh/xxxxxx/photos.zip # It has also been copied to the clipboard!

Encrypt your files with openssl before the transfer

# Encrypt files with password using openssl $ cat /tmp/hello.txt|openssl aes-256-cbc -pbkdf2 -e|curl -X PUT --upload-file "-" https://transfer.sh/test.txt # Download and decrypt $ curl https://transfer.sh/1lDau/test.txt|openssl aes-256-cbc -pbkdf2 -d > /tmp/hello.txt

Upload a file or directory in Windows

#Save this as transfer.cmd in Windows 10 (which has curl.exe) @echo off setlocal EnableDelayedExpansion EnableExtensions goto main :usage echo No arguments specified. >&2 echo Usage: >&2 echo transfer ^<file^|directory^> >&2 echo ... ^| transfer ^<file_name^> >&2 exit /b 1 :main if "%~1" == "" goto usage timeout.exe /t 0 >nul 2>nul || goto not_tty set "file=%~1" for %%A in ("%file%") do set "file_name=%%~nxA" if exist "%file_name%" goto file_exists echo %file%: No such file or directory >&2 exit /b 1 :file_exists if not exist "%file%\" goto not_a_directory set "file_name=%file_name%.zip" pushd "%file%" || exit /b 1 set "full_name=%temp%\%file_name%" powershell.exe -Command "Get-ChildItem -Path . -Recurse | Compress-Archive -DestinationPath ""%full_name%""" curl.exe --progress-bar --upload-file "%full_name%" "https://transfer.sh/%file_name%" popd goto :eof :not_a_directory curl.exe --progress-bar --upload-file "%file%" "https://transfer.sh/%file_name%" goto :eof :not_tty set "file_name=%~1" curl.exe --progress-bar --upload-file - "https://transfer.sh/%file_name%" goto :eof

Comments

  1. Great article by the great author, it is very massive and informative but still preaches the way to sounds like that it has some beautiful thoughts described so I really appreciate this article. Best send big files through link service provider.

    ReplyDelete

Post a Comment

Popular posts from this blog

Install Google Playstore on Pendo Pad 4.0 and rooting the device.

Coles selling the Pendo 7" Android Pad running Ice Cream Sandwich 4.03, however by default it does not come with Google Play Store. Rather it has the China "store" GetJar, which only have limited Apps available. In order to get the  Google Play store install on device. Firstly you have to root the device to gain root access. 1. Download unlockroot from : www.unlockroot.com/ 2. Connect the device to a windows PC, install and run the program. Make sure window machine has the necessary driver to access android pad.  If device driver is not available. Download and install the driver from: http://developer.android.com/tools/extras/oem-usb.html Make sure set the android device to USB Debugging mode to allow the unlockroot to root the device: Enable the USB debugging mode from : Setting -> Developer Options -> USB debugging Click on Root to root the device. After that, install the google play store by downloading it and transfer it to

Linux command to install software for various Distro

Ubuntu (*buntu, Mint linux) Apt-get install apt-get update apt-get remove apt-get dist-upgrade apt-get purge Fedora/RHEL/CentOS yum install yum update yum remove Opensuse yast2 --install yast2 --remove zypper update Freebsd  pkg_add pkg_delete Gentoo emerge package # Install emerge -C package # Remove a package emerge -s keyword # Search for packages (package names only) emerge -u package # update the package Arch pacman -U package.pkg.tar.xz # Local package install pacman -Syy # Refresh package databases pacman -Syu # Update installed packages pacman -S package # Install package pacman -R package # Remove package