This repository contains a Bash CLI script (gofile.sh
) that interacts with the Gofile.io API. It allows you to upload files, create folders, update content, manage direct links, and more—all from the command line.
-
Store and manage your Gofile API Token:
Easily save your token in a config file (~/.config/gofile-cli/config
) without hardcoding it. -
Upload files:
Upload any file to Gofile, either to a new public folder or to an existing folder in your account. -
Create and manage folders:
Create subfolders in your Gofile account, set folder attributes (name, public, expiry date, etc.). -
Retrieve account and folder info:
Fetch details about your account, list contents of folders, and manage them from the CLI. -
Search:
Search for files/folders by name or tags within a specified folder. -
Direct links:
Create/update/delete direct links for files or folders ( ZIP for folder downloads ) with optional password protection, IP/domain restrictions, and expiry times. -
Copy, move, and import content:
Restructure your Gofile account contents by copying/moving to different folders—or import public content into your own root. -
Reset your token:
Invalidate your current token and receive a new one if necessary.
- Bash (tested on Linux; Windows under WSL should also work).
- curl for making HTTP requests.
- jq for parsing JSON in the script.
-
Clone this repository:
git clone https://github.com/Ognisty321/gofile-cli.git # or your username if forked cd gofile-cli
-
Make the script executable:
chmod +x gofile.sh
-
(Optional) Copy or symlink
gofile.sh
to a directory in yourPATH
:sudo cp gofile.sh /usr/local/bin/gofile # Or create a symlink: # ln -s /path/to/gofile.sh /usr/local/bin/gofile
Now you can run ./gofile.sh
(or just gofile
if it’s in your PATH
).
-
Set your Gofile.io API Token:
./gofile.sh set-token <YOUR_API_TOKEN>
This creates (or updates) a config file in
~/.config/gofile-cli/config
:API_TOKEN=abc123def456
-
Verify that your token is stored:
./gofile.sh show-token
Usage: ./gofile.sh <command> [arguments]
Commands:
set-token <TOKEN>
Save your Gofile.io API token to config
show-token
Print the currently stored API token
get-servers [zone]
Get available servers. Optional zone: eu | na
upload-file <filePath> [folderId] [zoneOrServer]
Upload a file.
- folderId: (optional) the folder ID to upload into.
- zoneOrServer: (optional) either "eu" or "na" for zone selection, or "storeX" for a specific server.
create-folder <parentFolderId> [folderName]
Create a new folder in parentFolderId (folderName optional)
update-content <contentId> <attribute> <newValue>
Update content attributes: name, description, tags, public, expiry, password
delete-content <contentIds>
Permanently delete files/folders by comma-separated IDs
get-content <contentId>
Retrieve detailed info about a folder (only works with folder IDs)
search-content <folderId> <searchString>
Search files/folders by name/tags recursively under the specified folder
create-direct-link <contentId> [expireTime] [sourceIpsAllowed] [domainsAllowed] [auth]
Create a direct link (for files/folders).
- expireTime: Unix timestamp
- sourceIpsAllowed: comma-separated IPs
- domainsAllowed: comma-separated domains
- auth: comma-separated "user:pass" pairs
update-direct-link <contentId> <directLinkId> [expireTime] [sourceIpsAllowed] [domainsAllowed] [auth]
Update an existing direct link’s settings
delete-direct-link <contentId> <directLinkId>
Delete a direct link permanently
copy-content <contentsId> <destFolderId>
Copy multiple files/folders (comma-separated) to a new folder
move-content <contentsId> <destFolderId>
Move multiple files/folders (comma-separated) to a new folder
import-content <contentsId>
Import public content (comma-separated) to your root folder
get-account-id
Retrieve the account ID associated with your current token
get-account <accountId>
Retrieve detailed info about the specified account
reset-token <accountId>
Reset your current token. You’ll receive a new token via email.
- Usage:
./gofile.sh set-token <YOUR_API_TOKEN>
- Description: Writes your API token to
~/.config/gofile-cli/config
.
- Usage:
./gofile.sh show-token
- Description: Displays the currently stored token (if any).
- Usage:
# All servers (no zone filter) ./gofile.sh get-servers # Only servers in 'eu' zone ./gofile.sh get-servers eu # Only servers in 'na' zone (may return empty if none exist) ./gofile.sh get-servers na
- Description: Retrieves a list of servers. If a zone is specified, the script will post-process the response to filter servers in that zone only.
- Note: Gofile might fall back to other zones if none match the requested zone.
-
Usage:
./gofile.sh upload-file <filePath> [folderId] [zoneOrServer]
- filePath: Local path to the file you want to upload.
- folderId (optional): If omitted, your file uploads to a new public folder (guest mode or your default account root, depending on token).
- zoneOrServer (optional):
eu
orna
to automatically pick the first server from that zone.- Or specify a server name directly, e.g.
store6
.
-
Examples:
# Upload a file to your default zone ./gofile.sh upload-file "/path/to/video.mp4" # Upload to a specific folderId in the 'eu' zone ./gofile.sh upload-file "/path/to/video.mp4" MyFolderId eu # Upload to a folder using a specific server ./gofile.sh upload-file "/path/to/video.mp4" MyFolderId store6
- Usage:
./gofile.sh create-folder <parentFolderId> [folderName]
- Description: Creates a subfolder in the specified
parentFolderId
. IffolderName
is omitted, Gofile auto-generates a folder name.
- Usage:
./gofile.sh update-content <contentId> <attribute> <newValue>
- Attributes:
name
: Rename file/folder.description
: Change folder description.tags
: Comma-separated tags.public
:"true"
or"false"
(folders only).expiry
: Unix timestamp (folders only).password
: String password (folders only).
- Usage:
./gofile.sh delete-content <contentIds>
- Description: Permanently delete one or more files/folders by passing comma-separated IDs.
- Usage:
./gofile.sh get-content <folderId>
- Description: Retrieves detailed info for a folder and its contents (files/subfolders).
- Usage:
./gofile.sh search-content <folderId> <searchString>
- Description: Recursively searches in
folderId
for files/folders matchingsearchString
in name or tags.
- Usage:
./gofile.sh create-direct-link <contentId> [expireTime] [sourceIpsAllowed] [domainsAllowed] [auth]
- Description: Creates a direct access link to a file/folder.
expireTime
: Unix timestamp (optional).sourceIpsAllowed
: Comma-separated IPs (optional).domainsAllowed
: Comma-separated domains (optional).auth
: Comma-separateduser:pass
pairs (optional).
- Usage:
./gofile.sh update-direct-link <contentId> <directLinkId> [expireTime] [sourceIpsAllowed] [domainsAllowed] [auth]
- Description: Updates an existing direct link’s configuration.
- Usage:
./gofile.sh delete-direct-link <contentId> <directLinkId>
- Description: Permanently removes a direct link without deleting the underlying content.
- Usage:
./gofile.sh copy-content <contentsId> <destFolderId>
- Description: Copies multiple files/folders (comma-separated) to another folder.
- Usage:
./gofile.sh move-content <contentsId> <destFolderId>
- Description: Moves multiple files/folders to another folder.
- Usage:
./gofile.sh import-content <contentsId>
- Description: Imports public content (by ID) into your account’s root folder.
- Usage:
./gofile.sh get-account-id
- Description: Retrieves the account ID associated with your current token.
- Usage:
./gofile.sh get-account <accountId>
- Description: Retrieves detailed information about a specific account ID.
- Usage:
./gofile.sh reset-token <accountId>
- Description: Immediately invalidates your current token and sends a new token to your Gofile-registered email.
-
Set your token and verify:
./gofile.sh set-token abc123def456 ./gofile.sh show-token
-
Get servers (all, eu, or na):
./gofile.sh get-servers # Show all possible servers ./gofile.sh get-servers eu # Show EU servers only ./gofile.sh get-servers na # Show NA servers only (might be empty)
-
Upload a file:
# Default server pick: ./gofile.sh upload-file "/path/to/myvideo.mp4" # Specify folder and zone: ./gofile.sh upload-file "/path/to/myvideo.mp4" MyFolderId eu # Specify folder and direct server name: ./gofile.sh upload-file "/path/to/myvideo.mp4" MyFolderId store6
-
Create a folder:
./gofile.sh create-folder rootFolderId "My New Folder"
-
Update content (rename folder):
./gofile.sh update-content myFolderId name "Super Cool Folder"
-
Delete content:
./gofile.sh delete-content fileId1,fileId2
-
Get folder details:
./gofile.sh get-content myFolderId
-
Search:
./gofile.sh search-content myFolderId "music"
-
Create a direct link:
./gofile.sh create-direct-link myFileId 1704067200 "192.168.1.10" "example.com" "alice:secret"
-
Copy content:
./gofile.sh copy-content fileId1,fileId2 destinationFolderId
-
Move content:
./gofile.sh move-content folderId1,fileId99 anotherFolderId
-
Import content:
./gofile.sh import-content publicFileId1,publicFolderId2
-
Get account ID:
./gofile.sh get-account-id
-
Reset token:
./gofile.sh reset-token 12345
This project is released under the MIT License. Feel free to modify and distribute as needed. Contributions are welcome!