kDriveClient 1.0.0
See the version list below for details.
dotnet add package kDriveClient --version 1.0.0
NuGet\Install-Package kDriveClient -Version 1.0.0
<PackageReference Include="kDriveClient" Version="1.0.0" />
<PackageVersion Include="kDriveClient" Version="1.0.0" />
<PackageReference Include="kDriveClient" />
paket add kDriveClient --version 1.0.0
#r "nuget: kDriveClient, 1.0.0"
#:package kDriveClient@1.0.0
#addin nuget:?package=kDriveClient&version=1.0.0
#tool nuget:?package=kDriveClient&version=1.0.0
π kDriveClient SDK
kDriveClient is a modern C# SDK to simplify file upload and download with Infomaniak kDrive API, including:
- Automatic direct or chunked upload
- Dynamic chunk size based on your actual bandwidth
- Download with redirect support
- Built-in rate limiting (60 requests/min)
- Strong error handling (deserialized API errors)
- Native .NET logging support
π¦ Installation
dotnet add package kDriveClient
dotnet add package Microsoft.Extensions.Logging.Console
β‘ Usage
Upload (automatic direct/chunked selection)
using Microsoft.Extensions.Logging;
var logger = LoggerFactory.Create(builder => builder.AddConsole())
.CreateLogger<KDriveClient>();
var client = new KDriveClient("your_token", "your_drive_id", logger: logger);
var file = new KDriveFile
{
Name = "example.txt",
DirectoryPath = "/Private/test",
Content = File.OpenRead("example.txt"),
CreatedAt = (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
LastModifiedAt = (int)new FileInfo("example.txt").LastWriteTimeUtc.Subtract(DateTime.UnixEpoch).TotalSeconds
};
try
{
var response = await client.UploadAsync(file);
Console.WriteLine($"Uploaded file ID: {response.Id}");
}
catch (KDriveApiException ex)
{
Console.WriteLine($"API error: {ex.Error}");
}
Download
// Into memory
var stream = await client.DownloadFileAsync("file_id");
Console.WriteLine($"File downloaded");
using var fs = File.Create("downloaded.txt");
await stream.CopyToAsync(fs);
Console.WriteLine($"File saved to {fs.Name}");
// Directly into a file
using var outFile = File.Create("downloaded_direct.txt");
await client.DownloadFileAsync("file_id", outFile);
Console.WriteLine($"File downloaded and saved to {fs.Name}");
β Advanced features
β Custom parallelism
var client = new KDriveClient("your_token", "your_drive_id", true, 8);
β
Inject your own HttpClient (for testing/mocking)
var fakeHttpClient = new HttpClient(new FakeHandler()) { BaseAddress = new Uri("https://api.infomaniak.com") };
var client = new KDriveClient("your_token", "your_drive_id", true, 4, null, httpClient: fakeHttpClient);
β Built-in error object
catch (KDriveApiException ex)
{
Console.WriteLine($"Error: {ex.Error.Result}, Code: {ex.Error.Error.Code}, Description: {ex.Error.Error.Description}");
}
β Features
- Automatic direct or chunked upload mode based on speed test
- Dynamic chunk size calculation (~1s worth of data with safety margin)
- Download with redirect support
- Rate limit of 60 requests/min
- Deserialized error responses (no manual parsing)
- Native logger support (Microsoft.Extensions.Logging)
- Testable: inject your own
HttpClient
π€ Contributing
PRs and issues welcome! Letβs improve this SDK together.
π License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.6)
- Microsoft.Extensions.Logging.Console (>= 9.0.6)
- System.Threading.RateLimiting (>= 9.0.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
β¨ New features
Automatic direct / chunked upload based on real speed test
Dynamic chunk size with ~1s worth of data per chunk (with margin)
Download with redirect support
Built-in 60 req/min rate limiting
Deserialized API error responses (KDriveApiException)
Native logger support (ILogger<KDriveClient>)
Injection support for HttpClient (easier unit/integration testing)
🔧 Improvements
Clean modular structure: easy to extend or port
Full .NET 7/8/9 compatibility