Skip to content

Instantly share code, notes, and snippets.

@jasonbyrne
Created April 7, 2017 05:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonbyrne/deae86064624c12a081359316fe4e7fa to your computer and use it in GitHub Desktop.
Save jasonbyrne/deae86064624c12a081359316fe4e7fa to your computer and use it in GitHub Desktop.
Upload a file to to file.io with an expiration (requires jq to be installed)
#!/bin/bash
if [[ ! $1 ]]; then
echo "No file provided"
exit
fi
if [ ! -f "$1" ]; then
echo "File does not exist"
echo "$1"
echo ""
exit;
fi
if [[ ! $2 ]]; then
echo "Expiration not privded"
exit
fi
RESPONSE=`curl -F "file=@$1" https://file.io/?expires="$2"`
LINK=`echo "$RESPONSE" | jq '.link'`
LEN=${#LINK}
SUBSTR_LEN=($LEN-2)
LINK=${LINK:1:${SUBSTR_LEN}}
echo "Download link: $LINK"
exit
@jasonbyrne
Copy link
Author

Usage:
./temp-upload.sh /path/to/file/you/want/to.upload 2d

The 2d part means the link will expire after two days. You can also do "w" for weeks and "m" for months. There is no option (that I know of) with file.io to do minutes or hours or seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment