Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <https://gofile.io> via Terminal (CLI). Written in Bash.

## Usage

```bash
./upload.sh <path/to/file>
```

You'll see the link after the Upload gets Complete

## Features:
- Upload Files to https://gofile.io Using their API
## Features

- Upload Files to <https://gofile.io> 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

- <https://gofile.io> - 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.
29 changes: 22 additions & 7 deletions upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down