Warning KuboDownloader pulls from the IPFS Shipyard over HTTP, and will not work when the user is offline.
Automatically downloads and extracts the correct Kubo binary for the running operating system and architecture
Works on Windows, Linux, MacOS and FreeBSD (with .NET 5+)
Works on x64, x86, ARM and ARM64
var httpClient = new HttpClient();
var ipfsClient = new IpfsClient { ApiUri = new Uri(...) };
// Latest binary, downloaded via default HttpClient
IFile latestKuboBinary = await KuboDownloader.GetLatestBinaryAsync();
// Latest binary, downloaded via custom HttpClient
IFile latestKuboBinary = await KuboDownloader.GetLatestBinaryAsync(httpClient);
// Latest binary, downloaded via custom IpfsClient
IFile latestKuboBinary = await KuboDownloader.GetLatestBinaryAsync(ipfsClient);
var httpClient = new HttpClient();
var ipfsClient = new IpfsClient { ApiUri = new Uri(...) };
// v0.15.0 binary, downloaded via default HttpClient
IFile kuboBinary = await KuboDownloader.GetBinaryVersionAsync(Version.Parse("0.15.0"));
// v0.15.0 binary, downloaded via custom HttpClient
IFile kuboBinary = await KuboDownloader.GetBinaryVersionAsync(httpClient, new Version(0, 15, 0));
// v0.15.0 binary, downloaded via custom IpfsClient
IFile kuboBinary = await KuboDownloader.GetBinaryVersionAsync(ipfsClient, new Version(0, 15, 0));
The IFile
you're given is created by crawling the contents of the compressed archive directly from Http or Ipfs, and is not saved on disk. The stream supports reading and seeking, with lazy-loading of the underlying stream.
You can treat this IFile
like any other file in OwlCore.Storage, whether copying it to another location (local, cloud, etc) or providing it to other tooling.
This helper can be combined with the KuboBootstrapper
to automatically download the binary, only when needed. It requires no additional copying or setup.
To learn how to use the bootstrapper, see the docs.
The returned object is an IFile
, which can be saved or copied as needed.
// The returned file can be copied to any modifiable folder, if needed.
IModifiableFolder destination = new SystemFolder("/some/path");
var copiedFile = await destination.CreateCopyOfAsync(kuboBinary);
The Id of a file or folder is contractually guaranteed to be unique within that filesystem (while Name may not be).
Given this, simply save the copiedFile.Id
string. After a restart, provide it to GetItemAsync()
or GetItemRecursiveAsync
on the destination folder to retrieve it again.
var kuboBinary = await destination.GetItemAsync(copiedFileId);