Skip to main content

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

  • localPath is the path of a local file or folder, in the form of directory/filename, such as ./index.js, static/css/index.css, etc.
  • cloudPath is the path of a Cloud storage file or folder relative to the root directory, in the form of directory/filename, such as index.js, static/css/index.js, etc.
⚠️ Precautions

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

version tip

The tcb storage rm command has been added since v3.0.0 and is the recommended delete command with more powerful features.

Command Change

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:

ParameterDescription
--dirTarget is a folder (recursive deletion)
--recursiveSame as --dir
--forceForce deletion without confirmation prompt
--dry-runDry 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

version tip

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:

ParameterDescription
--moveMove Files (by copying then deleting the source file)
--forceForce overwrite existing files
--skipSkip existing files
-e, --env-id <envId>Environment ID

Search Files

version tip

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:

ParameterDescription
-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)
--regexHandle pattern as a regular expression

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

Deprecated (v3.0.0+)

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 CommandNew Command
tcb storage:uploadtcb storage upload
tcb storage:downloadtcb storage download
tcb storage:deletetcb storage rm
tcb storage:listtcb storage list
tcb storage:urltcb storage url
tcb storage:detailtcb storage detail
tcb storage:get-acltcb permission
tcb storage:set-acltcb permission

Command Quick Reference

CommandDescription
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-aclObtain access permissions (deprecated, use tcb permission)
tcb storage set-aclSet access permissions (deprecated, use tcb permission)
tcb storage rules getObtain permission rules (deprecated, use tcb permission)
tcb storage rules updateUpdate permission rules (deprecated, use tcb permission)