If you just want to download assets with very minimal code, we got you! All you need to know is the public repository name and owner, and you can download release assets easily. No need to setup api keys and clients.
I think it's easier to show how it works, here is a simple console demo
to download assets from the latest release of fossa-client-desktop
using GithubReleaseDownloader;
namespace ConsoleApp;
public static class Program
{
public static void Main()
{
// The owner and repo to download from, and target path
var owner = "libremindsph";
var repo = "fossa-client-desktop";
var downloadPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
// Get last release using .GetLatest(), can substitute with other available methods
var release = ReleaseManager.Instance.GetLatest(owner, repo);
if (release is null) return;
// In this case, we download all assets
AssetDownloader.Instance .DownloadAllAssets(release, downloadPath);
}
}
And done! That easy. If you need to monitor the progress, we also got you covered. just use the progressChanged
callback.
using GithubReleaseDownloader;
using GithubReleaseDownloader.Entities;
namespace ConsoleApp;
public static class Program
{
public static void Main()
{
// The owner and repo to download from, and target path
var owner = "libremindsph";
var repo = "fossa-client-desktop";
var downloadPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
// Get last release using .GetLatest(), can substitute with other available methods
var release = ReleaseManager.Instance.GetLatest(owner, repo);
if (release is null) return;
// In this case, we download all assets
AssetDownloader.Instance.DownloadAllAssets(release,downloadPath, progressChanged: RunOnProgressChanged);
}
// This is being executed when the progress changes
private static void RunOnProgressChanged(DownloadInfo downloadInfo)
{
if (downloadInfo.DownloadPercent == 1.0)
{
Console.WriteLine($"Finished downloading: {downloadInfo.Name}");
return;
}
if (downloadInfo.DownloadPercent == 0)
{
Console.WriteLine($"Start downloading: {downloadInfo.Name}");
return;
}
Console.WriteLine($"Progress({downloadInfo.Name}): {downloadInfo.DownloadPercent:P}");
}
}
Nuget Cli dotnet add package GithubReleaseDownloader --version 1.0.0
Nuget Link https://www.nuget.org/packages/GithubReleaseDownloader/1.0.0
Method | Description | Parameters |
---|---|---|
GetWithTag() | Gets a release from the repo with the specified tag | string: owner string: repo string: tag |
GetWithTagAsync() | Asynchronous overload of GetWithTag() |
string: owner string: repo string: tag |
GetLatest() | Gets the latest release from the repo | string: owner string: repo |
GetLatestAsync() | Asynchronous overload of GetLatest() |
string: owner string: repo |
GetAll() | Gets all releases from the repo | string: owner string: repo |
GetAllAsync() | Asynchronous overload of GetAll() |
string: owner string: repo |
Only the parameters with an asterisk *
are required, the rest are optional
Method | Description | Parameters |
---|---|---|
DownloadAllAssets() |
Downloads all release assets | Release : release*string : savePath*Action<DownloadInfo> progressChanged |
DownloadAllAssetsAsync() |
Asynchronous overload of DownloadAllAssets() |
Release : release*string : savePath*Action<DownloadInfo> progressChanged |
DownloadAssets() |
Downloads selected release assets | IEnumerable<ReleaseAsset> assets*string savePath*Action<DownloadInfo> progressChanged |
DownloadAssetsAsync() |
Asynchronous overload of DownloadAssets() |
IEnumerable<ReleaseAsset> assets*string savePath*Action<DownloadInfo> progressChanged |
DownloadAsset() |
Downloads a single release asset | IEnumerable<ReleaseAsset> assets*string savePath*string fileNameAction<DownloadInfo> progressChanged |
DownloadAssetAsync() |
Asynchronous overload of DownloadAsset() |
IEnumerable<ReleaseAsset> assets*string savePath*string fileNameAction<DownloadInfo> progressChanged |
I do this freely to help the community ❤️, but supporting this project means I can afford more time to spend in these projects. Who knows, we might be able to create something even more awesome! Click on the sponsor button in this repository to show some love for this project ❤️
This project was developed with the help of jetbrains products, thank you JetBrains for supporting this project by providing licences to the JetBrains Suite!