[英]GitHub API to retrieve files uploaded via issue comment
是否可以检索通过问题评论上传的文件? 假设我有
owner: foo
repo: bar
并且路径上有一个文件
https://github.com/foo/bar/files/1000001/text.txt
那么这个 API 调用会检索数据吗,特别是如果 repo 是私有的?
我不这么认为,但不确定如何以另一种方式实现它。
await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
owner: 'foo',
repo: 'bar',
path: 'files/1000001/text.txt'
})
没有 REST API 端点来检索已上传到评论的文件。 您提到的 API 调用( GET /repos/{owner}/{repo}/contents/{path} )仅用于检索存储库源文件的内容。
const { data: { body } } = await octokit.request('GET /repos/{owner}/{repo}/issues/comments/{comment_id}', {
owner: 'foo',
repo: 'bar',
comment_id: '692203785'
})
// `body` is "[file.xlsx](https://github.com/keita-makino/so-63841841/files/5220043/file.xlsx)\r\n"
提取 URL ( https://github.com/keita-makino/so-63841841/files/5220043/file.xlsx
) 并使用octokit.request("https://github.com/keita-makino/so-63841841/files/5220043/file.xlsx")
。
我不确定这是否适用于私有存储库,因为亚马逊 S3 的重定向 URL 可能需要仅适用于浏览器的身份验证。
我还建议联系 GitHub 支持: https : //support.github.com/contact 。 也许他们正计划为通过评论上传的文件添加 REST API 端点,也许已经有一种使用 GraphQL 端点的方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.