跳到主要内容

tcb storage objects download

把 Storage bucket 中的对象下载到本地。

v3.4.0+

PG 模式存储命令自 @cloudbase/cli@3.4.0 起提供。

语法​

tcb storage objects download <key> [localPath] -b <bucketId> [options]

参数​

参数必填说明默认值
<key>是对象名—
[localPath]否本地路径;省略时输出到 stdout;指向已存在目录时自动拼接 key 的 basenamestdout
-b, --bucket <bucketId>是Bucket ID—
-m, --method <method>否GET / HEADGET
--download <filename>否触发浏览器下载,等价于 ?download=<filename>—
--if-none-match <etag>否If-None-Match 头,仅认证下载路径生效—
--if-modified-since <date>否If-Modified-Since 头—
--range <range>否Range 头,用于断点续传—
--overwrite否本地路径已存在时允许覆盖false
--json否仅返回元信息 { status, headers },不落盘—

已登录时走认证下载路径,可访问 private 与 public bucket;未登录时回退到公开下载,仅能访问 public bucket。--method HEAD 与 --json 模式不写本地文件。

示例​

tcb storage objects download test/hello.txt ./hello.txt -b my-bucket
tcb storage objects download test/hello.txt -b my-bucket --range bytes=0-1023
tcb storage objects download test/hello.txt -b my-bucket --json