Transfer.sh, share files easily from the terminal

about transfer.sh

In the next article we are going to take a look at Transfer.sh. This is a service of free accommodation. The service allows users to store, sync, and share files online to other users. All this we will be able to do from our terminal in Ubuntu.

Transfer.sh us allows file upload without the need for an account, up to a maximum of 10 GB. The files are stored in the service and are available for download for 14 days. After this period the files will be automatically deleted.

This is one of the many utilities that we can find in terminal. Some of them are CLI-based and some are GUI-based, some are free and some are paid. When it comes to sharing or transferring large files from the command line over the Internet, there are really only a few that work. One of them is Transfer.sh. Despite its name, it is not a script, it is a website. This page will allow us to share files over the Internet easily and quickly. No need to install anything except cURL or wget. Most Gnu / Linux distributions have these utilities pre-installed. So you don't need to install anything, really.

Transfer.sh it will allow us to upload files of up to 10 GB in one go. All shared files automatically expire after 14 days (more than enough time to share them), so you don't need to worry about manually deleting them. Will allow us upload a single file or group of them in one go. All files can be encrypted before uploading. We can scan files loaded with malware or viruses with ClamAV or VirusTotal. And of course it is completely free. For more information about this project, see the project website.

Sharing or transferring files using transfer.sh is not complicated at all. First, let's see how to load the files.

Upload files with Transfer.sh

All you have to do is run the following command to share the files:

curl --upload-file ENTREUNOS.pdf https://transfer.sh/ENTREUNOS.pdf

In this example, ENTREUNOS.pdf is located on my desktop.

https://transfer.sh/bZNd9/ENTREUNOSYCEROS.pdf

When the upload is complete, the service returns us the unique download link for the file, like the one seen in the previous line. You can pass this URL to anyone you want to download and use this file.

It is also possible upload files using 'wget'.

wget --method PUT --body-file=/home/sapoclay/Escritorio/ENTREUNOS.pdf https://transfer.sh/ENTREUNOSYCEROS.pdf -O - -nv

This utility it will allow us to load several files at once. To do this we will only have to execute an order with the same structure as the following:

curl -i -F filedata=@/home/sapoclay/Escritorio/bash_tips.pdf -F filedata=@/home/sapoclay/Escritorio/bash_tips_2.pdf https://transfer.sh/

transfer.sh upload multiple files

Download files

To download the file, execute us vast with using a command like the following one. In it we indicate the URL to download and the name of the file that will be created on our computer:

curl https://transfer.sh/bZNd9/ENTREUNOSYCEROS.pdf -o entreunosyceros.pdf

transfer.sh download files

Alternatively, we can preview the download and perform it from our Web browser. Just put the download link in the address bar and click the "download" button to download the shared file.

transfer.sh download from browser

Encrypt and upload files

For more security this application will allow us to encrypt and upload the files. To encrypt and upload files, we will execute something like the following in the terminal:

cat /home/sapoclay/Escritorio/archivo.txt|gpg -ac -o-|curl -X PUT --upload-file "-" https://transfer.sh/archivo.txt

We will be asked to enter a passphrase twice. The application will give us the download link of the encrypted file. Which will be something like the following:

https://transfer.sh/140GNQ/archivo.txt

Decrypt and download files

To decrypt and download the previous encrypted file, we will only have to execute:

curl https://transfer.sh/140GNQ/archivo.txt|gpg -o- > /home/sapoclay/Escritorio/entreunosyceros.txt

Add alias

If we plan to use this service frequently, we can consider adding aliases to the .bashrc or .zshrc files to make this command even easier to use.

If you use BASH shell, edit the ~ / .bashrc file:

sudo vi ~/.bashrc

Add the following lines to the end of the file.

transfer() { if [ $# -eq 0 ]; then echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi 
tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile; }

Save and close the file. Then run the following command to make your saved changes take effect.

source ~/.bashrc

Now, you will be able to upload and download files as shown below.

transfer archivo.txt

The latter, as you can see, will make the use of this useful terminal program much easier.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Badrom said

    Hello Damian!

    Thanks for this great contribution!
    I take this opportunity to ask you that I have put it in a small script and I had to use an "=" in the conditional of the parameter.
    In this way I have saved the basename….
    Do you think it's a good idea or one day petera ..

    1.    Damian Amoedo said

      As long as it works for you as you want, what is the problem? Salu2.