【发布时间】:2017-02-15 18:18:02
【问题描述】:
我正在使用 Trello API 将文件上传(和附加)到卡片。
我给https://api.trello.com/1/cards/my-card-id/attachments发了一个帖子
消息正文是 JSON
{ file: file_contents, 'BuildSheet.html': filename, mimeType: 'text/html' }
file_contents is a string that contains the body of the file I want to attach.
这行得通。该文件被上传并附加。当我获取卡片数据时,这就是我看到的有关此附件的内容。
{"id":"58a496bc751c0c2fa260630f",
"bytes":3291,
"date":"2017-0215T17:58:20.881Z",
"edgeColor":null,
"idMember":"55240806b8ca85db897253c4",
"isUpload":true,
"mimeType":"text/html",
"name":"BuildSheet.html",
"previews":[],
"url":"https://trello-attachments.s3.amazonaws.com/589ca323806c1d80cc03ea12/589ceda619d5936e8428f15b/1f62074b6700e61e611a90beaa8c2c73/Upload"}
您可以看到 mimeType 设置正确。名字也是正确的。但是,如果您从 UI 内部上传,则 url 不会使用文件名。所以该文件没有 .html 扩展名。
当我下载文件时,它包含这个标题
Content-Type: application/octet-stream
应该是文本/html。这会导致浏览器下载文件而不是显示它。
我做错了吗?有没有其他人遇到过这个问题?
另外有没有办法让 Trello 在构造 url 时使用文件名?
【问题讨论】:
标签: trello