跳到主要内容

tcb storage objects sign

生成对象的临时下载链接,加 --upload 切换为上传链接。

v3.4.0+

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

语法​

# 下载签名
tcb storage objects sign <keys...> -b <bucketId> [--expires-in <seconds>] [--json]

# 上传签名
tcb storage objects sign <key> --upload -b <bucketId> [--upsert] [--json]

参数​

参数必填说明默认值
<keys...>是下载模式 1~500 个;上传模式仅允许 1 个—
-b, --bucket <bucketId>是Bucket ID—
--upload否切换到上传签名模式false
--expires-in <seconds>否过期时间,单位为秒,≥ 1,仅下载模式600
--upsert否允许覆盖,等价于 x-upsert: true,仅上传模式false
--json否下载模式输出 [{ path, signedURL, error }];上传模式输出 { url, token }—

互斥规则:

  • --upload 与 --expires-in 互斥。
  • 下载模式传 --upsert 会被拒绝。
  • --upload 一次只能签 1 个 key。

示例​

tcb storage objects sign test/hello.txt -b my-bucket --expires-in 3600
tcb storage objects sign test/hello.txt -b my-bucket --upload --upsert