stat 命令用于查询对象元数据。
注意:
命令格式
./coscli stat cos://<bucket-name>/<key> [flags]
stat 命令包含以下参数:
参数格式 | 参数用途 | 示例 |
cos://<bucket-name> | 使用桶别名访问:cos://example-alias 使用桶名称访问:cos://examplebucket-1250000000 |
stat 命令包含以下可选 flag:
flag 简写 | flag 全称 | flag 用途 |
无 | --version-id | 指定对象版本 |
说明:
操作示例
设置存储桶清单
查询存储桶 testbucket 下 file1文件的元数据:
./coscli stat cos://testbucket/file1
输出以下结果:
INFO[2026-08-25 11:48:32] Object: cos://testbucket/file1INFO[2026-08-25 11:48:32] ETag: "asdhashahashdhahqwhqwhehq"INFO[2026-08-25 11:48:32] Content-Type: application/octet-streamINFO[2026-08-25 11:48:32] Content-Length: 1024INFO[2026-08-25 11:48:32] Last-Modified: Sun, 27 Apr 2025 03:24:01 GMTINFO[2026-08-25 11:48:32] Cache-Control:INFO[2026-08-25 11:48:32] Content-Disposition:INFO[2026-08-25 11:48:32] Content-Encoding:INFO[2026-08-25 11:48:32] Content-Language:INFO[2026-08-25 11:48:32] Expires:INFO[2026-08-25 11:48:32] x-cos-storage-class:INFO[2026-08-25 11:48:32] x-cos-version-id: nullINFO[2026-08-25 11:48:32] x-cos-object-type:INFO[2026-08-25 11:48:32] x-cos-hash-crc64ecma: 90818123123131313