How to upload a Zip File using Octokit?

折月煮酒 提交于 2019-12-25 17:48:28

问题


How to upload a zip file using Octokit.net? I am new to Octokit.net anyone could you possible provide code snippet?


回答1:


The ocktokit.net docs are quite complete, read the docs well.

This is an example from the docs:

var client = new GitHubClient(new ProductHeaderValue("my-cool-app"));
var basicAuth = new Credentials("username", "password"); // NOTE: not real credentials
client.Credentials = basicAuth;

using(var archiveContents = File.OpenRead("output.zip")) { // TODO: better sample
    var assetUpload = new ReleaseAssetUpload() 
    {
         FileName = "my-cool-project-1.0.zip",
         ContentType = "application/zip",
         RawData = archiveContents
    };
    var release = client.Repository.Release.Get("octokit", "octokit.net", 1);
    var asset = await client.Repository.Release.UploadAsset(release, assetUpload);
}


来源:https://stackoverflow.com/questions/56521441/how-to-upload-a-zip-file-using-octokit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!