Find out how to Add and Share Information From the Terminal Utilizing Switch.sh

Do you want to speed up file uploading and sharing on Linux? How to use Transfer.sh from the command line.

In general, file sharing involves logging into a storage provider, manually locating the file, and uploading it using the graphical user interface of a web browser or application. While the time wasted during these intermediate steps doesn't seem like much, it adds up every time you want to upload or share a file.

But sharing files doesn't have to be a hassle anymore. With the Linux terminal, this is done in no time at all. Thanks to tools like transfer.sh, A simple command on your terminal is enough to upload a file.

What is Transfer.sh?

Transfer.sh is a free platform that enables easy and fast file sharing via the Linux shell. Uploading a file is as simple as running a cURL command or shell function with the file you want to upload as a parameter. You can also use these commands on Windows 10 by running a Linux bash shell on it.

More Info: How to Get the Linux Bash Shell on Windows 10

Here are some important features that transfer.sh offers:

  • Does not require a GUI, uses the command line.

  • Upload files up to 10 GB in size.

  • Files are only stored for 14 days.

  • Optionally, encrypt the files with GPG before transferring them.

  • Limit the number of downloads and days that the file is available.

Upload a file via cURL

Client URL (cURL) is a command line tool for transferring data to and from a server using various network protocols. Uploading a file via cURL and transfer.sh is a straightforward process. All you have to do is open your Linux terminal and use the following syntax to upload a file:

curl –upload-file https://transfer.sh

In the above command, make sure you replace with the actual path of the file you want to upload.

When you run the command, you will be given a URL that you can share with other people so they can download your uploaded file.

You can tweak the above command to change the name and extension of the uploaded file this way:

curl –upload-file https://transfer.sh/

In the example above, cURL renamed the file hello.txt to test.md before uploading. When you visit the download link, you will be prompted for the test.md File instead of the original file.

What's more, you can even set the maximum number of downloads allowed and the maximum number of days the file can be downloaded by adding some headers to the cURL command. Here is an example that illustrates this function:

Here the cURL command consists of two HTTP headers: Max downloads and Max days. You can change the value after the colons as you wish.

Upload via shell function

While the cURL command is pretty simple, you can take it a step further and make it even easier by creating a shell function. You can then use this shell function to replace the entire cURL command with a single word.

To get started, navigate to /At home Directory on your Linux computer and open the .bashrc or .zshrc File depending on the shell used. Feel free to use any Linux text editor of your choice. Add the shell function given below to the end of the file and save it once you're done.

transfer () {if ($ # -eq 0); then echo "No arguments given.
Use:
transfer
… | transfer "> & 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;}

For the shell function to work, you must close the existing terminal instances and start a new one. Alternatively, you can run Source ~ / .bashrc if you're using the bash shell, or Source ~ / .zshrc if you are using the Z shell. Now you can save files with the transfer Command from your Linux terminal.

Related: How to Change the Default Shell on Linux Using chsh

File sharing made easy on Linux

While transfer.sh is a great utility for getting a shareable download url for your files, it is not an alternative to completely replacing your cloud storage. It is exceptional to temporarily share your files as your files will be stored for a maximum of 14 days.

For longer lasting personal storage, you can contact cloud storage providers. Do not worry. Many cloud service providers offer a free tier that you can use to decide whether to make the purchase.

The 5 best Linux cloud storage solutions in 2021

Do you need to sync with the cloud on your Linux PC? Here are five of the best Linux-compatible cloud services available today.

Continue reading

About the author

Nitin Ranganath
(17 articles published)

Nitin is an avid software developer and computer engineering student who develops web applications using JavaScript technologies. He works as a freelance web developer and enjoys writing for Linux and programming in his free time.

More
By Nitin Ranganath

Subscribe to our newsletter

Subscribe to our newsletter for tech tips, reviews, free e-books, and exclusive offers!

One more step …!

Please confirm your email address in the email you just sent.

Leave a Reply

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