A simple but robust Bash CLI (gofile.sh) for interacting with the Gofile.io API. Upload files (single or multiple), manage folders/contents, search, create direct links, and handle account actions, straight from your terminal.
Uploads default to Gofile’s global upload endpoint, and the CLI can reuse the returned
folderId/guestTokento keep multiple uploads in the same folder automatically.
-
Token management
- Store your token in
~/.config/gofile-cli/config(XDG-aware). - Support for
--token(per-command override) andGOFILE_TOKENenv var. show-tokenprints a masked token.
- Store your token in
-
Guest mode
- Run commands without auth via
--guest(useful for basic uploads / public operations).
- Run commands without auth via
-
Smarter uploads
- Uses Gofile’s global upload endpoint by default.
- Upload multiple files in one command; if you don’t pass
--folder, the CLI reuses the folder returned by the first upload. - Optional
--progressfor a progress bar. - Optional server selection by
--zone eu|naor--server storeX(legacy-style).
-
More ergonomic commands
lsprints a human-friendly listing of a folder.- Aliases:
servers,mkdir,rm,search.
-
Password hashing support
- Some API endpoints accept/require a SHA-256 hex password hash; the CLI supports
--password(hashes for you) and--password-hash(use your own). - Helper command:
hash-password.
- Some API endpoints accept/require a SHA-256 hex password hash; the CLI supports
-
Direct links improvements
- Create/update direct links with IP/domain allowlists, auth pairs, and domainsBlocked.
-
Better output and error handling
- Default pretty JSON output; switch to raw/compact when needed.
- Fails clearly on HTTP/API errors.
- Bash (Linux; macOS and WSL typically work too)
- curl
- jq
- For password hashing (one of):
sha256sum(GNU), orshasum(macOS), oropenssl
-
Clone this repository:
git clone https://github.com/Ognisty321/gofile-cli.git cd gofile-cli -
Make the script executable:
chmod +x gofile.sh
-
(Optional) Put it on your PATH:
sudo cp gofile.sh /usr/local/bin/gofile # or: # ln -s "$PWD/gofile.sh" /usr/local/bin/gofile
Now you can run ./gofile.sh (or gofile if it’s in your PATH).
./gofile.sh set-token <YOUR_API_TOKEN>
./gofile.sh show-tokenConfig file location (XDG-aware):
- Default:
~/.config/gofile-cli/config
export GOFILE_TOKEN="<YOUR_API_TOKEN>"
./gofile.sh get-account-id./gofile.sh --token "<YOUR_API_TOKEN>" get-account-id./gofile.sh unset-tokenUsage:
./gofile.sh [global options] <command> [args...]
--token <TOKEN>: use TOKEN for this invocation (overrides config/env)--guest: do NOT send Authorization header for this invocation-v, --verbose: verbose output (repeat for more)--raw: print raw JSON (no jq formatting)--compact: print compact JSON (jq -c)-h, --help: show help
-
set-token <TOKEN>Save token to config -
show-tokenShow token (masked) -
unset-tokenRemove token from config -
hash-password <PASSWORD>Print SHA-256 hex hash (useful for endpoints requiring password hashes)
get-servers [zone](alias:servers) Get available servers. Optional zone:eu|na
-
upload <file...> [--folder <folderIdOrUrl>] [--zone eu|na] [--server storeX] [--url <uploadUrl>] [--progress] [--json]Notes:
- Uses the global upload endpoint by default.
- If
--folderis omitted, the CLI reuses the folder returned by the first upload when uploading multiple files.
-
upload-file <filePath> [folderId] [zoneOrServer]Backwards-compatible wrapper for older usage (preferuploadgoing forward).
create-folder <parentFolderIdOrUrl> [folderName] [--public true|false](alias:mkdir)ls <folderIdOrUrl> [--json]get-content <folderIdOrUrl> [--password <pw> | --password-hash <sha256hex>]search-content <folderIdOrUrl> <searchString> [--password <pw> | --password-hash <sha256hex>](alias:search)update-content <contentIdOrUrl> <attribute> <newValue>delete-content <contentIdsCsv>(alias:rm)copy-content <contentsIdCsv> <destFolderIdOrUrl> [--password <pw> | --password-hash <sha256hex>]move-content <contentsIdCsv> <destFolderIdOrUrl> [--password <pw> | --password-hash <sha256hex>]import-content <contentsIdCsv> [--password <pw> | --password-hash <sha256hex>]
Tip: For most commands you can pass either a content ID or a share URL like
https://gofile.io/d/AbCdEf, the CLI extracts the ID automatically.
create-direct-link <contentIdOrUrl> [expireTime] [sourceIpsAllowedCsv] [domainsAllowedCsv] [authCsv] [domainsBlockedCsv]update-direct-link <contentIdOrUrl> <directLinkId> [expireTime] [sourceIpsAllowedCsv] [domainsAllowedCsv] [authCsv] [domainsBlockedCsv]delete-direct-link <contentIdOrUrl> <directLinkId>
get-account-idget-account <accountId>whoamiPrints account id + root folder id (if available)reset-token <accountId>Invalidates your token and triggers a new one (sent via Gofile email)
./gofile.sh set-token abc123def456
./gofile.sh show-token
./gofile.sh whoami./gofile.sh upload "/path/to/video.mp4" --progress./gofile.sh upload ./a.bin ./b.bin ./c.bin --progress./gofile.sh upload "./video.mp4" --folder MyFolderId./gofile.sh upload "./video.mp4" --zone eu
# or:
./gofile.sh upload "./video.mp4" --server store6./gofile.sh ls https://gofile.io/d/AbCdEf./gofile.sh search-content MyFolderId "music files"./gofile.sh hash-password "secret"
./gofile.sh get-content MyFolderId --password "secret"
# or:
./gofile.sh get-content MyFolderId --password-hash <sha256hex>./gofile.sh create-direct-link MyFileId 1704067200 "192.168.1.10" "example.com" "alice:secret" "bad.com"MIT License. See LICENSE.