-
Notifications
You must be signed in to change notification settings - Fork 0
/
gf.sh
27 lines (21 loc) · 876 Bytes
/
gf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
# Check if a file argument is provided
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 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
# Display the download link
# Quoting $LINK preserves any spaces or special characters in the URL
echo "$LINK"
# Print a blank line for better readability
echo