This project is a port of the Ruby net::github:upload library to the .Net Framework.
It allows for uploading of files to the "Downloads" section of a github project.
If you want to automate the uploading of files to the "Download" section of a github project, from say a PowerShell script.
This library makes use of the HTML Agility Pack and the Newtonsoft JSON.Net library.
Uploading
var uploader = new GithubUploader("github-login", "gihub-secret-token");
string fileLocation = uploader.Upload(new UploadInfo
{
ContentType = "text/plain",
Data = new byte[] {1, 2, 3, 4}, // alternatively, set the Property "FileName" with a path to a file.
Description = "Test",
Name = "name",
Repository = "RepositoryXYZ"
});
// file location will be in the format: http://github.s3.amazonaws.com/downloads%2Fgithubuploadtest%2FGitHubUploadDotNet-Test%2Fname29ad9d6e-9fac-4a76-84e3-cae384c97ed9
Console.WriteLine(fileLocation);
Listing Files
var uploader = new GithubUploader("github-login", "gihub-secret-token");
var files = uploader.ListFiles("RepositoryXYZ");
foreach (var file in files)
{
Console.WriteLine("File: {0}, Id: {1}, Size: {2}, Link: {3}", file.Name, file.Id, file.Size, file.Link);
}
Deleting Files
var uploader = new GithubUploader("github-login", "gihub-secret-token");
var files = uploader.ListFiles("RepositoryXYZ");
foreach (var file in files)
{
uploader.Delete("RepositoryXYZ", file.Id);
}
// alternatively, you can also just "DeleteAll"
uploader.DeleteAll("RepositoryXYZ");
- GitHubUploader.Core - Core implementation for uploading to Github.
- GitHubUploader.Tests - Test project - includes both unit and integration tests (uses the XUnit.Net test framework).
The original versions of this library
The current maintainer of this Port to .Net is Alex Henderson a.k.a @bittercoder.