#!/bin/bash
# First-time upload to Gofile (anonymous account).
# Returns: folderId, token, and download link.
ENDPOINT="https://upload.gofile.io/uploadfile"
if [ $# -lt 1 ]; then
  echo "Usage: $0 <file-path>"
  exit 1
fi
FILE_PATH="$1"
response=$(curl -s -X POST "$ENDPOINT" -F "file=@${FILE_PATH}")
status=$(echo "$response" | jq -r '.status')
if [ "$status" != "ok" ]; then
  echo "Upload failed: $response"
  exit 1
fi
downloadPage=$(echo "$response" | jq -r '.data.downloadPage')
folderId=$(echo "$response" | jq -r '.data.parentFolder')
token=$(echo "$response" | jq -r '.data.guestToken')
echo "Download link: $downloadPage"
echo "Folder ID: $folderId"
echo "Token: $token"
echo "FOLDER_ID=\"$folderId\"" > gofile_credentials.sh
echo "TOKEN=\"$token\"" >> gofile_credentials.sh
echo "Saved credentials to gofile_credentials.sh"
