Created
April 7, 2017 05:03
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.