问题描述
owner: foo
repo: bar
https://github.com/foo/bar/files/1000001/text.txt
然后,此API调用将检索数据,尤其是如果回购是私有的吗?
我不这么认为,但不确定如何以其他方式实现它。
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")
下载。
我不确定这是否适用于私有存储库,因为到Amazon S3的重定向URL可能需要仅适用于浏览器的身份验证。
我还建议联系GitHub支持:https://support.github.com/contact。也许正在计划为带注释的上传文件添加REST API端点,也许已经有了使用GraphQL端点的方法