How to Upload File via Command Prompt to Server
By and large, 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 application. While the time wasted during these intermediate steps may not seem like much, it keeps on calculation up every fourth dimension y'all wish to upload or share a file.
Simply sharing files doesn't take to be tiresome anymore. With the Linux concluding, yous can do this in a jiffy. Thanks to tools liketransfer.sh, all information technology takes is a elementary command on your concluding to upload a file.
What Is Transfer.sh?
Transfer.sh is a gratis platform that enables easy and fast file sharing via the Linux trounce. Uploading a file is as unproblematic as running a gyre command or a shell function with the file you want to upload every bit the parameter. You tin likewise use these commands on Windows x past running a Linux bash shell on it.
Here are some significant features that transfer.sh offers:
- Requires no GUI, uses the command line.
- Upload files with sizes up to 10GB.
- Files are only stored for 14 days.
- Optionally encrypt the files with GPG before 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 data to and from a server, using diverse network protocols. Uploading a file via curl and transfer.sh is a straightforward process. All you lot have to practise is open up your Linux concluding and use the following syntax to upload a file:
ringlet --upload-file <path-to-file> https://transfer.sh
In the higher up command, brand sure to supersede<path-to-file>with the actual path of the file you desire to upload.
On running the control, you'll go a URL that y'all can share with other people for them to download your uploaded file.
You tin tweak the higher up command to change the proper noun and extension of the uploaded file in this manner:
curl --upload-file <path-to-file> https://transfer.sh/<file_name.extension>
In the in a higher place case, ringlet renamed the filehello.txt totest.md before uploading. On visiting the download link, you'll be prompted to download thetest.md file instead of the original file.
Moreover, you tin fifty-fifty set 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 gyre command. Here's an example that illustrates this feature:
Here, the scroll command consists of 2 HTTP headers:Max-Downloads andMax-Days. You can change the value after the colons every bit per your requirements.
Uploading via Shell Function
Although the whorl command is pretty simple, you can take it a stride farther and brand information technology fifty-fifty easier by creating a beat role. You lot can and then employ this shell office to substitute the whole cURL command with a unmarried word.
To get started, navigate to the /home directory on your Linux automobile and open the.bashrcor.zshrc file depending on the shell you lot employ. Experience free to use any Linux text editor of your preference. Paste the vanquish function given below to the finish of the file and save it once done.
transfer(){ if [ $# -eq 0 ];and so echo "No arguments specified.
Usage:
transfer <file|directory>
... | transfer <file_name>">&2;return 1;fi;if tty -s;then file="$one";file_name=$(basename "$file");if [ ! -e "$file" ];then repeat "$file: No such file or directory">ⅈreturn 1;fi;if [ -d "$file" ];then file_name="$file_name.zip" ,;(cd "$file"&&zip -r -q - .)|ringlet --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=$i;curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null;fi;}
For the shell function to work, you will take to close the existing terminal instances and get-go a new ane. Alternatively, y'all can runsource ~/.bashrc if y'all utilise the bash shell, orsource ~/.zshrc if y'all use the Z shell. At present, you lot tin can upload files using thetransfer command from your Linux terminal.
File Sharing Made Easy 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 deject storage entirely. Information technology is exceptional for sharing your files temporarily as it merely stores your files for 14 days maximum.
For longer-lasting personal storage, you tin can lean towards deject storage providers. Don't worry. Many cloud service providers offer a free tier that y'all can use to make up one's mind whether you want to make the purchase.
About The Author
Source: https://www.makeuseof.com/upload-and-share-files-from-terminal-using-transfer-sh/
0 Response to "How to Upload File via Command Prompt to Server"
Post a Comment