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 的 basename | stdout |
-b, --bucket <bucketId> | 是 | Bucket ID | — |
-m, --method <method> | 否 | GET / HEAD | GET |
--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