附件
attachments 命令(别名 attachment、a)封装了 Redmine 的附件 API,让你既能查看附件的元数据,也能下载其字节内容。下载会复用当前 profile 的服务器地址和 API 密钥,并直接流式写入磁盘 - 无需 curl,也无需手动提取密钥。
redmine attachments get <id> [flags]别名:show、view、metadata。通过 GET /attachments/:id.json 获取附件的 ID、文件名、大小、内容类型、描述、作者和创建时间。表格输出还会显示下载 URL(若存在);json 会返回所有字段,包括 content_url。
| 标志 | 描述 |
|---|---|
-o, --output |
输出格式:table、json、csv |
redmine attachments get 42redmine attachments get 42 -o jsonredmine attachments get 42 -o csvdownload
Section titled “download”redmine attachments download <id> [flags]别名:dl、get-file。使用当前 profile 进行认证,将附件的原始字节流式写入磁盘(或 stdout)。响应是流式处理的,不会整体缓存在内存中,因此下载大文件也很安全。
| 标志 | 描述 |
|---|---|
-d, --dir |
保存到的目录,使用附件的真实文件名(目录不存在时自动创建) |
--path |
精确的目标文件路径。使用 - 可流式输出到 stdout |
-o, --output |
确认信息的格式:json 打印结果对象;否则向 stderr 写入一行可读信息 |
若不指定目标标志,文件会以 ./<文件名> 保存到当前目录。
# 保存为 ./<文件名>redmine attachments download 42redmine attachments download 42 --dir ./downloadsredmine attachments download 42 --path ./logo.pngredmine attachments download 42 --path - | file -redmine attachments download 42 --dir ./downloads -o json