英文:
Download asset from private repo in java with kohsuke github api
问题
我正在尝试从私人存储库下载资产。
我使用kohsuke API,它允许我查看所有发布版本,并且我可以从公共存储库下载资产,但在私人存储库中,我仍然可以看到所有发布版本,但无法下载它们。
获取以下错误:
java.io.FileNotFoundException: https://github.com/*用户名*/*仓库名*/releases/download/*标签名*/asset.jar
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1909)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1509)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:245)
at java.base/java.net.URL.openStream(URL.java:1117)
at org.apache.commons.io.FileUtils.copyURLToFile(FileUtils.java:1460)
令牌具有所有权限。
英文:
I am trying to download assets from a private repository.
I use the kohsuke api, it allows me to see all releases and i can download assets from public repos, but in private repos i still can see all the releases but not download them.
Getting the following error:
java.io.FileNotFoundException: https://github.com/*username*/*repo*/releases/download/*tag*/asset.jar
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1909)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1509)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:245)
at java.base/java.net.URL.openStream(URL.java:1117)
at org.apache.commons.io.FileUtils.copyURLToFile(FileUtils.java:1460)
The token has all the permissions.
答案1
得分: 1
API资产的路由在GHAsset.java
中,可能对于私有仓库下载不完整:
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/releases/assets/" + getId();
这是7年前的代码(提交编号178c9f)
可能缺少Accept: application/octet-stream
头信息,详情见此处(另一个项目中提到)
英文:
The API route for assets is in GHAsset.java
and might not be complete for private repository download:
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/releases/assets/" + getId();
It is a code from 7 years ago (commit 178c9f)
And it might be missing the Accept: application/octet-stream
header mentioned here (in a separate project)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论