【发布时间】:2018-07-09 18:26:12
【问题描述】:
我目前正在尝试使用 openproject api v3 在我的网站中显示有关 openproject 工作包的数据(我正在使用带有 symfony 的 PHP。)。
获取一般数据(主题、描述、优先级等)没有问题,但我不确定如何向用户显示附件。
我尝试使用"/api/v3/work_packages/".$id."/attachments",但是返回的json中没有图片:
"_type":"Collection",
"total":1,
"count":1,
"_embedded":{
"elements":[{
"_type":"Attachment",
"id":1888,"fileName":"128-128-logo.png",
"fileSize":9583,
"description":{"format":"plain","raw":null,"html":""},
"contentType":"image/png",
"digest":{"algorithm":"md5","hash":"/*-hash-here-*/"},
"createdAt":"2018-07-09T16:49:26Z",
"_links":{
"self":{"href":"/api/v3/attachments/1888","title":"128-128-logo.png"},
"author":{"href":"/api/v3/users/7","title":"User Name"},
"container":{"href":"/api/v3/work_packages/1697","title":"Subject -\u003E Test Query OpenProject"},
"downloadLocation":{"href":"/attachments/1888/128-128-logo.png"},
"delete":{"href":"/api/v3/attachments/1888","method":"delete"}
}
}]
},
"_links":{
"self":{"href":"/api/v3/work_packages/1697/attachments"}
}
我也试过直接链接到附件,但得到了
"_type":"Attachment",
"id":1888,
"fileName":"128-128-logo.png",
"fileSize":9583,
"description":{"format":"plain","raw":null,"html":""},
"contentType":"image/png",
"digest":{"algorithm":"md5","hash":"/*-hash-here-*/"},
"createdAt":"2018-07-09T16:49:26Z",
"_links":{
"self":{"href":"/api/v3/attachments/1888","title":"128-128-logo.png"},
"author":{"href":"/api/v3/users/7","title":"User Name"},
"container":{"href":"/api/v3/work_packages/1697","title":"Subject -\u003E Test Query OpenProject"},
"downloadLocation":{"href":"/attachments/1888/128-128-logo.png"},
"delete":{"href":"/api/v3/attachments/1888","method":"delete"}
}
下载位置不是 API url 并返回 406 - 如果我尝试使用 img 标签 (<img src="https://XXXXXX.openproject.com/attachments/1888/128-128-logo.png">) 访问它,则未经授权
所以我想我的问题是:即使我的用户没有我的 openproject 帐户,我如何向他们显示附件?
【问题讨论】:
标签: json openproject