How to Upload File in Ubuntu Terminal
Mostly, file sharing involves logging into a storage provider, manually locating the file, and uploading it via the graphical user interface of a web browser or awarding. While the fourth dimension wasted during these intermediate steps may not seem like much, it keeps on adding up every time you wish to upload or share a file.
But sharing files doesn't accept to be tedious anymore. With the Linux terminal, you lot can do this in a jiffy. Thanks to tools similartransfer.sh, all it takes is a simple command on your terminal to upload a file.
What Is Transfer.sh?
Transfer.sh is a free platform that enables like shooting fish in a barrel and fast file sharing via the Linux vanquish. Uploading a file is as simple as running a cURL command or a shell role with the file yous want to upload every bit the parameter. You tin also use these commands on Windows 10 by running a Linux bash shell on information technology.
Here are some significant features that transfer.sh offers:
- Requires no GUI, uses the control line.
- Upload files with sizes upwards to 10GB.
- Files are only stored for xiv days.
- Optionally encrypt the files with GPG earlier transfer.
- Limit the number of downloads and days for which the file will be available.
Uploading a File via cURL
Client URL (cURL) is a command-line tool used for transferring information to and from a server, using diverse network protocols. Uploading a file via cURL and transfer.sh is a straightforward process. All you have to do is open up your Linux terminal and use the post-obit syntax to upload a file:
curl --upload-file <path-to-file> https://transfer.sh
In the above control, make sure to replace<path-to-file>with the bodily path of the file yous want to upload.
On running the control, you'll become a URL that you can share with other people for them to download your uploaded file.
You can tweak the above command to alter the proper name and extension of the uploaded file in this manner:
gyre --upload-file <path-to-file> https://transfer.sh/<file_name.extension>
In the in a higher place case, cURL renamed the filehello.txt totest.md before uploading. On visiting the download link, you'll exist prompted to download theexamination.md file instead of the original file.
Moreover, y'all can even fix the maximum number of downloads allowed and the maximum number of days for which the file will exist downloadable by adding some headers to the coil control. Here'south an instance that illustrates this feature:
Here, the cURL control consists of 2 HTTP headers:Max-Downloads andMax-Days. You tin modify the value after the colons as per your requirements.
Uploading via Shell Function
Although the cURL command is pretty elementary, you tin take information technology a step farther and make information technology even easier by creating a shell function. Y'all can then employ this shell role to substitute the whole cURL command with a single word.
To become started, navigate to the /home directory on your Linux machine and open the.bashrcor.zshrc file depending on the crush you use. Experience gratis to use whatsoever Linux text editor of your preference. Paste the shell office given below to the finish of the file and salvage it in one case washed.
transfer(){ if [ $# -eq 0 ];then echo "No arguments specified.
Usage:
transfer <file|directory>
... | transfer <file_name>">&2;render 1;fi;if tty -s;then file="$1";file_name=$(basename "$file");if [ ! -east "$file" ];then repeat "$file: No such file or directory">&2;return one;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/zero,;else cat "$file"|roll --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 piece of work, you will have to close the existing terminal instances and beginning a new i. Alternatively, yous can runsource ~/.bashrc if you apply the bash vanquish, orsource ~/.zshrc if you use the Z beat. Now, y'all can upload files using thetransfer command from your Linux last.
File Sharing Made Like shooting fish in a barrel on Linux
While transfer.sh is a great utility for obtaining a sharable download URL for your files, it isn't an alternative for replacing your cloud storage entirely. It is exceptional for sharing your files temporarily as it only stores your files for fourteen days maximum.
For longer-lasting personal storage, you can lean towards cloud storage providers. Don't worry. Many cloud service providers offer a free tier that you lot tin utilize to determine whether you want to make the purchase.
Nearly The Author
Source: https://www.makeuseof.com/upload-and-share-files-from-terminal-using-transfer-sh/
0 Response to "How to Upload File in Ubuntu Terminal"
Post a Comment