![]() |
VOOZH | about |
dotnet add package Backblaze.Client --version 1.1.2
NuGet\Install-Package Backblaze.Client -Version 1.1.2
<PackageReference Include="Backblaze.Client" Version="1.1.2" />
<PackageVersion Include="Backblaze.Client" Version="1.1.2" />Directory.Packages.props
<PackageReference Include="Backblaze.Client" />Project file
paket add Backblaze.Client --version 1.1.2
#r "nuget: Backblaze.Client, 1.1.2"
#:package Backblaze.Client@1.1.2
#addin nuget:?package=Backblaze.Client&version=1.1.2Install as a Cake Addin
#tool nuget:?package=Backblaze.Client&version=1.1.2Install as a Cake Tool
π NuGet Version
π NuGet Downloads
The Backblaze Agent (client) for .NET Core is an implementation of the Backblaze B2 Cloud Storage API. Backblaze B2 Cloud Storage provides the cheapest cloud storage available on the internet. Backblaze B2 Cloud Storage is ΒΌ of the price of other storage providers. Give it a try as the first 10 GB of storage is free.
For feature requests and bug reports, please open an issue on GitHub.
To install Backblaze.Agent run the following command:
> dotnet add package Backblaze.Agent
Work in Progress! Whilst we encourage users to play with the samples and test programs, this project has not yet reached a stable state.
You will need an key_id and an application_key to configure Backblaze Agent. You can obtain these from the Backblaze B2 Cloud Storage portal. See the Sample Project for an example of how to use this packages.
public void ConfigureServices(IServiceCollection services)
{
services.AddBackblazeAgent(options =>
{
options.KeyId = "[key_id]";
options.ApplicationKey = "[application_key]";
});
}
To get a list of backblaze buckets simply inject IStorageClient into your class and call the async client.
public class IndexModel : PageModel
{
private readonly IStorageClient _storage;
public IndexModel(IStorageClient storage)
{
_storage = storage;
}
[BindProperty]
public IEnumerable<BucketItem> Buckets { get; private set; }
public async Task<IActionResult> OnGetAsync()
{
Buckets = await _storage.Buckets.GetAsync();
if (Buckets == null)
{
return NotFound();
}
return Page();
}
}
Install the following packages:
> dotnet add package Backblaze.Client
> dotnet add package Microsoft.Extensions.Caching.Memory
> dotnet add package Microsoft.Extensions.Logging.Debug
Sample Code:
class Program
{
private static IStorageClient Client;
static async Task Main(string[] args)
{
try
{
var options = new ClientOptions();
var loggerFactory = LoggerFactory.Create(builder =>
{
builder
.AddFilter("Bytewizer.Backblaze", LogLevel.Trace)
.AddDebug();
});
var cache = new MemoryCache(new MemoryCacheOptions());
Client = new BackblazeClient(options, loggerFactory, cache);
await Client.ConnectAsync("[key_id]", "[application_key]");
var buckets = await Client.Buckets.GetAsync();
foreach (var bucket in buckets)
Console.WriteLine($"Bucket Name: {bucket.BucketName} - Type: {bucket.BucketType}");
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
}
}
}
Install the following package:
> dotnet add package Backblaze.Client
Sample Code:
class Program
{
private static IStorageClient Client;
static async Task Main(string[] args)
{
try
{
Client = new BackblazeClient();
Client.Connect("[key_id]", "[application_key]");
var buckets = await Client.Buckets.GetAsync();
foreach (var bucket in buckets)
{
Console.WriteLine($"Bucket Name: {bucket.BucketName} - Type: {bucket.BucketType}");
}
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
}
}
}
Upload File Stream
foreach (var filePath in Directory.GetFiles(@"c:\my\directory"))
{
using (var stream = File.OpenRead(filePath))
{
var results = await Client.UploadAsync("[BucketId]", new FileInfo(filePath).Name, stream);
}
}
Download File Stream
var files = new string[] { @"c:\my\directory\file1.txt", "file2.bat" };
foreach (var fileName in files)
{
using (var stream = File.Create(fileName))
{
var results = await Client.DownloadAsync("[BucketName]", fileName, stream);
}
}
Install the Microsoft.Extensions.Logging packages:
> dotnet add package Microsoft.Extensions.Logging.Debug
Tracing to the Debug window can be enabled with the following code:
services.AddLogging(builder =>
{
builder.AddDebug();
builder.AddFilter("Bytewizer.Backblaze", LogLevel.Trace);
});
services.AddBackblazeAgent(options =>
{
options.KeyId = "[key_id]";
options.ApplicationKey = "[application_key]";
});
The following table describes the Agent Options available:
| Option Name | Default | Description |
|---|---|---|
| KeyId | --- | Required - The key identifier used to authenticate. |
| ApplicationKey | --- | Required - The secret part of the key used to authenticate. |
| HandlerLifetime | 600 | The time in seconds that the message handler instance can be reused. |
| Timeout | 600 | The time in seconds to wait before the client request times out. |
| RetryCount | 5 | The number of times the client will retry failed requests before timing out. |
| RequestMaxParallel | 10 | The maximum number of parallel request connections established. |
| DownloadMaxParallel | 5 | The maximum number of parallel download connections established. |
| DownloadCutoffSize | 100MB | Download cutoff size for switching to chunked parts in bytes. |
| DownloadPartSize | 100MB | Download part size of chunked parts in bytes. |
| UploadMaxParallel | 3 | The maximum number of parallel upload connections established. |
| UploadCutoffSize | 100MB | Upload cutoff size for switching to chunked parts in bytes. |
| UploadPartSize | 100MB | Upload part size of chunked parts in bytes. |
| AutoSetPartSize | false | Use the recommended part size returned by the Backblaze service. |
| ChecksumDisabled | false | This is for testing use only and not recomended for production environments. |
| TestMode | --- | This is for testing use only and not recomended for production environments. |
services.AddBackblazeAgent(options =>
{
// This is for testing use only and not recomended for production environments.
options.TestMode = "fail_some_uploads";
});
The following test mode options are available to verify that your code correctly handles error conditions.
| Option String | Description |
|---|---|
| fail_some_uploads | Random uploads fail or become rejected by the service. |
| expire_some_account_authorization_tokens | Random account authorization tokens expire. |
| force_cap_exceeded | Cap exceeded conditions are forced. |
You will need an key_id and an application_key to configure Backblaze Test Agent settings.json file.
All source, documentation, instructions and products of this project are provided as-is without warranty. No liability is accepted for any damages, data loss or costs incurred by its use.
master - This is the branch containing the latest release - no contributions should be made directly to this branch.
develop - This is the development branch to which contributions should be proposed by contributors as pull requests. This development branch will periodically be merged to the master branch, and be released to NuGet Gallery.
Contributions to this project are always welcome. Please consider forking this project on GitHub and sending a pull request to get your improvements added to the original project.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 2 NuGet packages that depend on Backblaze.Client:
| Package | Downloads |
|---|---|
|
Backblaze.Agent
Backblaze.Agent is a high-performance .NET Core implementation of the Backblaze B2 Cloud Storage supporting dependency injection, caching and logging. |
|
|
StreamStore.S3.B2
Backblaze B2 storage for [StreamStore] asynchronous event sourcing library. |
This package is not used by any popular GitHub repositories.