Last active
November 11, 2024 18:40
-
-
Save rewida17/d8da334e2b8b6fa542ae4c744b4d7966 to your computer and use it in GitHub Desktop.
Upload files to gofile.io via api. Required curl and jq
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 | |
#Simple test/help | |
if [[ "$#" == '0' ]] | |
then | |
echo -e '\nPlease Select File\n' | |
#Great, file selected.. Lets upload that.. | |
elif [[ "$#" == '1' ]] | |
then | |
#Find Best server to upload | |
srv=$(curl -s https://apiv2.gofile.io/getServer | jq -r '.data|.server') | |
#Litlebit of hacking ;) (after upload, api respond with JSON that contain response code and file id) | |
upload=$(curl -X POST -# -F email=<MAIL_ADDRESS> -F description="${1%.*}" -F filesUploaded=@"$1" https://"$srv".gofile.io/upload | jq -r '.data|.code') | |
echo -e "\nYour Link: \nhttps://gofile.io/?c=$upload\n" | |
fi |
you've forgotten the
fi
at the end
yeah, exactly, it gives a syntax error
also sed can be used if you don't want to install jq
srv=$(curl -s https://apiv2.gofile.io/getServer | sed -E 's/.*?"server":"(.*?)".*?/\1/g')
upload=$(curl ... | sed -E 's/.*?"code":"(.*?)",.*?/\1/g')
and actually, only required parameter is file, if you dont want the other params,
srv=$(curl -s https://apiv2.gofile.io/getServer | sed -E 's/.*?"server":"(.*?)".*?/\1/g')
upload=$(curl -F [email protected] https://"$srv".gofile.io/upload | sed -E 's/.*?"code":"(.*?)",.*?/\1/g')
if you want to upload something quick without saving any scripts
curl -F [email protected] https://srv-file6.gofile.io/upload
link is gofile.io/d/code or gofile.io/?c=code
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you've forgotten the
fi
at the end