From aee8e6aab19555af6347ac9059d020bbe4e52174 Mon Sep 17 00:00:00 2001 From: FV Date: Sat, 27 Sep 2025 19:14:11 +0530 Subject: [PATCH] GoFile: adept to latest api changes --- upload.sh | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/upload.sh b/upload.sh index 8f6c97b..40ab77b 100755 --- a/upload.sh +++ b/upload.sh @@ -5,23 +5,22 @@ if [[ "$#" == '0' ]]; then echo -e 'ERROR: No File Specified!' && exit 1 fi -# Store the file path, preserving spaces -# $1 is the first command-line argument 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') +# Upload file with progress bar +# Use --progress-bar for a clean progress display +RESPONSE=$(curl --progress-bar -X POST -F "file=@$FILE" "https://upload.gofile.io/uploadfile") -# 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 +# Extract download link +LINK=$(echo "$RESPONSE" | jq -r '.data.downloadPage') -# Display the download link -# Quoting $LINK preserves any spaces or special characters in the URL -echo "$LINK" +# Check if upload succeeded +if [[ "$LINK" == "null" || -z "$LINK" ]]; then + echo -e "\n Upload failed! Full response:" + echo "$RESPONSE" + exit 1 +fi -# Print a blank line for better readability +# Print result +echo "$LINK" echo