Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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"
@jonasled

This comment has been minimized.

Copy link

jonasled commented Jun 19, 2020

you've forgotten the fiat the end

@sh4dowb

This comment has been minimized.

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
You can’t perform that action at this time.