Make terminal upload file using


“The art of programming is the skill of controlling complexity.” – Marijn Haverbeke

One day I needed to send some confidential file without signup. I googled about such service available on the internet and found

According to website -

Simply upload a file, share the link, and after it is downloaded, the file is completely deleted. For added security, set an expiration on the file and it is deleted within a certain amount of time, even if it was never downloaded. All files are encrypted when stored on our servers.

Most of my time goes into hitting commands on the terminal. can be accessed using any browser but I wanted to take this functionality to the terminal. I browsed that website and found an easy to use API.

At first, I tried to add a command for uploading files using an alias but it didn’t work very fine. Then I thought of writing function which will be foolproof and give some errors for helping out the user if they type something wrong.

Before going ahead make sure you have curl installed. If you are using Ubuntu, do this -

sudo apt-get install curl

Add the functionality Automatically

Run this command in your terminal.

For bash

curl -L >> ~/.bashrc
source ~/.bashrc

For zsh

curl -L >> ~/.zshrc
source ~/.zshrc

Add the functionality Manually

Add this to your ~/.bashrc or ~/.zsh file and restart your terminal. I tested this on bash and zsh in Ubuntu 18.04 LTS.

# Upload file via terminal using

# Author : Aman Roy (

upload () { if [ $# = 1 -o $# = 2 ];then if [ -f "$1" ];then if [ $# = 1 ];then curl -F "[email protected]$1" ;else if [[ "$2" =~ ^[1-9]+[wmy]$ ]];then curl -F "[email protected]$1"\?expires=$2;else echo $'Wrong expiration format.\neg. 1(w/m/y), etc.';fi;fi;else echo "file doesn't exist";fi;else echo $'usage: upload file_name.ext [expiration]\nexpiration format: 1-9(w/m/y) # (w)eeks, m(onths), (y)ear';fi }


For simple file upload, do this

upload file.ext

I am assuming here that the file name is file.ext.

You can also set an expiration period. By default, the expiration is set to 14 days. Pass 3rd argument for expiration. You can write any positive number followed by w, m or y. w is for weeks, m for months and y for years.

upload file.ext 3w # Keeps the data on server for 21 days.
upload file.ext 2m # Keeps the data on server for 60 days.
upload file.ext 1y # Keeps the data on server for 365 days.


It is very useful when you have to send some small sensitive data to another person. You can be assured that the file you are sending to another person will be deleted after he/she download it. The only drawback is that you can’t send a large file(file_size < 100MB). Try this script on different shell out there and if you find any bug please let me know.