从私有存储库中使用Kohsuke GitHub API在Java中下载资源。

huangapple go评论106阅读模式
英文:

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)

huangapple
  • 本文由 发表于 2020年5月29日 08:41:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/62076819.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定