无法在Octokit.net中将存储库内容作为.zip文件(zipball)获取

我使用Octokit.net version 0.9.0 (GitHub API for .NET)获取少量存储库的zip内容。

我已经有了我需要的存储库列表但是我无法将存储库的内容作为.zip文件(称为zipball)获取

到目前为止我尝试过的

 // ... client = new Client(...); // some authentication logic... // some other queries to GitHub that work correctly var url = "https://api.github.com/repos/SomeUser/SomeRepo/zipball"; var response = await this.client.Connection.Get( new Uri(url), new Dictionary(), null); var data = response.Body; var responseData = response.HttpResponse.Body; 

我尝试的问题

  1. data为空
  2. responseData.GetType().Name表示responseData的类型为string
  3. 当我尝试Encoding.ASCII.GetBytes(response.HttpResponse.Body.ToString()); 我得到无效的zip文件

response.HttpResponse.Body的价值

Quesion

在使用Octokit.net库进行身份validation后获取存储库的zipball的正确方法是什么?

我还在octokit.net存储库中打开了一个问题 。

在检查了Octokit的来源后,我认为这是不可能的(从版本0.10.0开始):

请参阅Octokit \ Http \ HttpClientAdapter.cs

 // We added support for downloading images. Let's constrain this appropriately. if (contentType == null || !contentType.StartsWith("image/")) { responseBody = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); } else { responseBody = await responseMessage.Content.ReadAsByteArrayAsync().ConfigureAwait(false); } 

响应主体( responseData )被转换为unicode字符串,因此它被破坏而不是二进制相同。 请参阅我的PR792 (需要用if (contentType == null || (!contentType.StartsWith("image/") && !contentType.StartsWith("application/")))替换if语句if (contentType == null || (!contentType.StartsWith("image/") && !contentType.StartsWith("application/"))) /”)&&!contentType.StartsWith(“application if (contentType == null || (!contentType.StartsWith("image/") && !contentType.StartsWith("application/"))) )来解决这个问题(然后就是使用System.IO.File.WriteAllBytes("c:\\test.zip", (byte[])responseData); )编写一个字节数组。