Skip to main content

Managing Files with CLI Tool

You can use the CloudBase CLI command-line tool to conveniently manage cloud storage resources for your project, such as batch uploading/downloading files/folders, obtaining file access links and information, and setting/getting cloud storage permissions.

Managing Cloud Storage with CLI Tool

The CloudBase CLI tool provides a series of commands to help you efficiently manage cloud storage resources.

Commands Overview

  • download: Download files or folders from cloud storage to local.
  • upload: Upload local files or folders to cloud storage.
  • delete: Delete files or folders in cloud storage.
  • list: List file or folder information in cloud storage.
tip

The tcb command requires specifying an environment ID, so you need to add -e envId after the command.

Downloading files/folders

  • cloudPath is the path relative to the root directory in cloud storage, and the full path must be specified.
  • localPath is the local folder path relative to the current directory.
tcb storage download cloudPath localPath -e envId

# When downloading folders, you need to specify the --dir parameter
tcb storage download cloudPath localPath --dir -e envId

For example, the following command downloads all files in the cloudbase directory under the root directory of cloud storage to the download directory in the local directory where the command is executed:

tcb storage download cloudbase ./download --dir -e envId

Uploading files/folders

tcb storage upload localPath cloudPath -e envId

When the CLI detects that localPath is a folder, it automatically uploads all files within the folder and overwrites them if they are uploaded repeatedly.

When cloudPath is not provided, files will be uploaded to the root directory of cloud storage while preserving the folder hierarchy. For example, the following command will directly upload the contents of the download folder in the project root directory to the root directory of cloud storage, where subfolders of download will become second-level directories in cloud storage.

tcb storage upload ./download -e envId

Deleting files/folders

# Delete files.
tcb storage delete cloudPath -e envId

# Delete folders.
tcb storage delete cloudPath --dir -e envId

Listing files/folders information

Without opening the Cloud Development Console or web console, you can also access information about folders or files in cloud storage via the CloudBase CLI tool.

tcb storage list cloudPath -e envId

For example, you can directly use the following command to list all files in the root directory of cloud storage, where files in subdirectories will be displayed with their paths.

More Information

To get more information about the CloudBase CLI tool, please visit the CloudBase CLI Command-Line Tool.