From a05780e37880c843e817615dc88f6587211a1008 Mon Sep 17 00:00:00 2001 From: Farrukh Seyer Hasan <59789349+farrukh2002@users.noreply.github.com> Date: Wed, 10 Dec 2025 16:58:29 +0530 Subject: [PATCH 1/2] useless cleanup. Because VS Code said me to do so. --- README.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ea8b2e0..d53db8e 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,30 @@ # GoFile Uploader -A Simple Script to upload Files to https://gofile.io via Terminal (CLI). Written in Bash. -## Usage: +A Simple Script to upload Files to via Terminal (CLI). Written in Bash. + +## Usage + ```bash ./upload.sh ``` + You'll see the link after the Upload gets Complete -## Features: -- Upload Files to https://gofile.io Using their API +## Features + +- Upload Files to Using their API - No File Size Limit - No Limit on Number of Files - Fast Servers - Free of Cost -## Requirements: +## Requirements + - ```curl``` and ```jq``` must be installed. ## -### Credits: -- https://gofile.io - For the Amazing Website to upload Unlimited files with Unlimited filesize to fast servers, for free! -- [Sushrut1101](https://github.com/Sushrut1101) - To make the Script +### Credits + +- - For the Amazing Website to upload Unlimited files with Unlimited filesize to fast servers, for free! +- [Sushrut1101](https://github.com/Sushrut1101) - Actual Author of this script. From 9f31d659c3890b291d5f83e8e42cb1f586bf414e Mon Sep 17 00:00:00 2001 From: Farrukh Seyer Hasan <59789349+farrukh2002@users.noreply.github.com> Date: Wed, 10 Dec 2025 16:58:02 +0530 Subject: [PATCH 2/2] fix: resolve "host null" error and update GoFile API handling Fixed the issue where the script failed with error: curl: (6) Could not resolve host: null.gofile.io. Changes: Added User-Agent headers to curl requests to bypass API restrictions. Added a fallback check: if the API returns null, defaults to store1 instead of crashing. Improved handling for uploads by verifying if we got a link. --- upload.sh | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/upload.sh b/upload.sh index 8f6c97b..85a0918 100755 --- a/upload.sh +++ b/upload.sh @@ -11,16 +11,31 @@ FILE="$1" # Query GoFile API to find the best server for upload # Use jq to parse JSON response and extract the server name -SERVER=$(curl -s https://api.gofile.io/servers | jq -r '.data.servers[0].name') +# Add a User-Agent (-A) because sometimes GoFile blocks default curl requests. +SERVER=$(curl -s -A "Mozilla/5.0" https://api.gofile.io/servers | jq -r '.data.servers[0].name') -# Upload the file to GoFile -# -# shows a progress bar -# -F specifies form data, "file=@$FILE" uploads the file content -# Use jq to parse JSON response and extract the download page URL -LINK=$(curl -# -F "file=@$FILE" "https://${SERVER}.gofile.io/uploadFile" | jq -r '.data|.downloadPage') 2>&1 +# Check if jq actually returned a valid server +# If not, default to "store1" or exit. +if [[ "$SERVER" == "null" || -z "$SERVER" ]]; then + echo "Warning: API did not return a valid server. Trying fallback (store1)..." + SERVER="store1" +fi + +echo "Uploading to ${SERVER}.gofile.io..." + +# Upload the file +# Add User-Agent here as well to ensure the upload is accepted. +LINK=$(curl -# -A "Mozilla/5.0" -F "file=@$FILE" "https://${SERVER}.gofile.io/uploadFile" | jq -r '.data.downloadPage') 2>&1 -# Display the download link +# Verify and display the download link # Quoting $LINK preserves any spaces or special characters in the URL + +if [[ "$LINK" == "null" || -z "$LINK" ]]; then + echo "Upload failed. Please check your internet or GoFile API status." + exit 1 +fi + +echo "Done!" echo "$LINK" # Print a blank line for better readability