Cloud storage
Cloud storage is a file storage capability provided by TCB for users. Users can operate on storage through CLI tools and SDK provided by TCB, such as uploading and downloading files. Files stored in Cloud storage are provided with CDN acceleration by default, enabling users to quickly access files in Cloud storage.
Path Description
localPathis the path of a local file or folder, in the form ofdirectory/filename, such as./index.js,static/css/index.css, etc.cloudPathis the path of a Cloud storage file or folder relative to the root directory, in the form ofdirectory/filename, such asindex.js,static/css/index.js, etc.
On Windows systems, localPath is in the local path format recognized by the system, typically using the \ separator. cloudPath is the cloud file path and must use the / separator.
File Upload
You can use the following command to upload files/folders. When the CLI detects that localPath is a folder, it will automatically upload all files within the folder.
tcb storage upload localPath cloudPath
# Specify upload retry count (0-10, default 1)
tcb storage upload localPath cloudPath --times 3
# Specify retry interval (ms, default 500)
tcb storage upload localPath cloudPath --interval 1000
File Download
You can use the following command to download files/folders. When downloading a folder, the --dir parameter must be specified.
# Download files.
tcb storage download cloudPath localPath
# Download folder
tcb storage download cloudPath localPath --dir
Download all files
When cloudPath is set to /, it means downloading all files in Cloud storage:
tcb storage download / localPath --dir
File Deletion
The tcb storage rm command has been added since v3.0.0 and is the recommended delete command with more powerful features.
The old command tcb storage delete has been deprecated and is retained for backward compatibility. Please use the new command tcb storage rm.
# Deleting a Single File
tcb storage rm cloudPath
# Delete folder (recursive deletion)
tcb storage rm cloudPath --dir
# Force Delete without Confirmation Prompt
tcb storage rm cloudPath --force
# Dry run, only display the files to be deleted, without actual execution
tcb storage rm cloudPath --dry-run
Command Parameters:
| Parameter | Description |
|---|---|
--dir | Target is a folder (recursive deletion) |
--recursive | Same as --dir |
--force | Force deletion without confirmation prompt |
--dry-run | Dry run, only display the files to be deleted, without actual deletion |
List Files
List files in the folder:
tcb storage list [cloudPath]
Copy/Move Files
This feature has been added since v3.0.0.
Copy or move files in the cloud (only at file level, folders not supported):
# Copy Files
tcb storage cp <sourcePath> <destPath>
# Move Files (by copying then deleting the source file)
tcb storage cp <sourcePath> <destPath> --move
# Force overwrite existing target files
tcb storage cp <sourcePath> <destPath> --force
# Skip existing target files
tcb storage cp <sourcePath> <destPath> --skip
Command Parameters:
| Parameter | Description |
|---|---|
--move | Move Files (by copying then deleting the source file) |
--force | Force overwrite existing files |
--skip | Skip existing files |
-e, --env-id <envId> | Environment ID |
Search Files
This feature has been added since v3.0.0.
Search cloud files by filename pattern:
# Basic Search (supports wildcards, such as *.jpg)
tcb storage search <pattern>
# Search in the specified directory
tcb storage search <pattern> --dir images/
# Filter by File Type (e.g., jpg, png, pdf)
tcb storage search <pattern> --type jpg
# Handle pattern as a regular expression
tcb storage search <pattern> --regex
Command Parameters:
| Parameter | Description |
|---|---|
-e, --env-id <envId> | Environment ID |
--dir <dir> | Specify the search directory (searches the root directory if not specified) |
--type <ext> | Filter by file type (e.g., jpg, png, pdf) |
--regex | Handle pattern as a regular expression |
Obtain File Access Link
Obtain temporary access link for a file:
tcb storage url cloudPath
# Specify link valid period (seconds, default: 3600)
tcb storage url cloudPath --expire 7200
Obtain File Information
Obtain basic file information:
tcb storage detail cloudPath
Permission Management
Commands such as tcb storage get-acl, tcb storage set-acl, tcb storage rules get, tcb storage rules update, and other storage permission commands have been deprecated since v3.0.0.
Please migrate to the tcb permission command for resource permission management. Refer to Permission Management for details.
Obtain Access Permissions
tcb storage get-acl
Set Access Permissions
tcb storage set-acl --acl <permission-value>
Optional permission values: READONLY, PRIVATE, ADMINWRITE, ADMINONLY
Obtain Permission Rules
tcb storage rules get
Update Permission Rules
# Use Preset Permissions
tcb storage rules update --acl READONLY
# Use Custom Rules (JSON Format)
tcb storage rules update --acl CUSTOM --rules '[{"role":"anyone","action":"read"}]'
Optional permission values: READONLY, PRIVATE, ADMINWRITE, ADMINONLY, CUSTOM (used for custom rules)
Notes on Deprecated Commands
The following old-format commands (colon-separated) are deprecated, but backward compatibility is maintained: please migrate to the new commands.
| Old Command | New Command |
|---|---|
tcb storage:upload | tcb storage upload |
tcb storage:download | tcb storage download |
tcb storage:delete | tcb storage rm |
tcb storage:list | tcb storage list |
tcb storage:url | tcb storage url |
tcb storage:detail | tcb storage detail |
tcb storage:get-acl | tcb permission |
tcb storage:set-acl | tcb permission |
Command Quick Reference
| Command | Description |
|---|---|
tcb storage upload <local> <cloud> | Upload a file/folder |
tcb storage download <cloud> <local> | Download a file/folder |
tcb storage rm <path> | Delete a file/folder (recommended) |
tcb storage list [path] | List files |
tcb storage cp <src> <dest> | Copy/move files |
tcb storage search <pattern> | Search files |
tcb storage url <path> | Obtain a temporary access link |
tcb storage detail <path> | Obtain file information |
tcb storage get-acl | Obtain access permissions (deprecated, use tcb permission) |
tcb storage set-acl | Set access permissions (deprecated, use tcb permission) |
tcb storage rules get | Obtain permission rules (deprecated, use tcb permission) |
tcb storage rules update | Update permission rules (deprecated, use tcb permission) |