我正在使用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设置正确。名字也是正确的。但是,url并不像从UI内部上传那样使用文件名。因此该文件没有.html扩展名。
当我下载该文件时,它包含以下标头
Content-Type: application/octet-stream它应该是text/html。这会导致浏览器下载该文件,而不是显示它。
我做错了什么吗?其他人也有这个问题吗?
另外,有没有办法让Trello在构建url时使用文件名?
发布于 2017-03-14 18:06:15
{文件: file_contents,'BuildSheet.html':文件名,mimeType:'text/html‘}
您尝试过使用密钥name吗?reference
https://stackoverflow.com/questions/42257159
复制相似问题