kDriveClient 1.0.3

dotnet add package kDriveClient --version 1.0.3
                    
NuGet\Install-Package kDriveClient -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="kDriveClient" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="kDriveClient" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="kDriveClient" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add kDriveClient --version 1.0.3
                    
#r "nuget: kDriveClient, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package kDriveClient@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=kDriveClient&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=kDriveClient&version=1.0.3
                    
Install as a Cake Tool

πŸš€ kDriveClient SDK

NuGet NuGet Downloads License: MIT

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 196 10/15/2025
1.0.2 219 8/13/2025
1.0.1 134 6/27/2025
1.0.0 158 6/21/2025

✨ New features
     - Improve chunk size estimation
     - Improve memory management
     - Complete kDrive File Object
     - Fix upload response wrapper
     - fix hash computation
     - bypass speed test if custom chunk size is provided
     - fix user-agent version
     - Add custom chunk size support and fix total_chunk_hash calculation
     - Add optional chunkSize parameter to KDriveClient constructor
     - Fix total_chunk_hash calculation to hash concatenated chunk hash hex strings
     - Use IncrementalHash for efficient hash computation during file chunking