Skip to content

Instantly share code, notes, and snippets.

@rewida17
Last active May 8, 2023 00:14
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rewida17/d8da334e2b8b6fa542ae4c744b4d7966 to your computer and use it in GitHub Desktop.
Save rewida17/d8da334e2b8b6fa542ae4c744b4d7966 to your computer and use it in GitHub Desktop.
Upload files to gofile.io via api. Required curl and jq
#!/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
@jonasled
Copy link

you've forgotten the fiat the end

@sh4dowb
Copy link

sh4dowb commented Jun 19, 2020

you've forgotten the fiat 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 filesUploaded=@file.txt https://"$srv".gofile.io/upload | sed -E 's/.*?"code":"(.*?)",.*?/\1/g')

if you want to upload something quick without saving any scripts

curl -F filesUploaded=@file.txt 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