Threem.File.UploaderKit
1.0.0
dotnet add package Threem.File.UploaderKit --version 1.0.0
NuGet\Install-Package Threem.File.UploaderKit -Version 1.0.0
<PackageReference Include="Threem.File.UploaderKit" Version="1.0.0" />
<PackageVersion Include="Threem.File.UploaderKit" Version="1.0.0" />
<PackageReference Include="Threem.File.UploaderKit" />
paket add Threem.File.UploaderKit --version 1.0.0
#r "nuget: Threem.File.UploaderKit, 1.0.0"
#:package Threem.File.UploaderKit@1.0.0
#addin nuget:?package=Threem.File.UploaderKit&version=1.0.0
#tool nuget:?package=Threem.File.UploaderKit&version=1.0.0
Threem.File.UploaderKit
A robust file upload solution for .NET applications that handles file storage in Azure Blob Storage with metadata management in either MongoDB or SQL Server.
Features
- Dual Storage Support: Store files in Azure Blob Storage while maintaining metadata in either:
- MongoDB (for document-based flexibility), or
- SQL Server (for relational data needs)
- Automatic Configuration: Simple setup with just one line of code
- Comprehensive File Handling:
- SHA256 hash generation
- MIME type detection
- File size tracking
- Custom metadata support
- Logging Integration: Built-in NLog support with configurable log directory
- Demo Project Available: Check out the Threem.File.UploaderKit Demo API for a working example
Installation
dotnet add package Threem.File.UploaderKit
β‘ Quick Start
1. Configure appsettings.json
{
"FileUploader": {
"StoreType": "SqlServer", // or "MongoDB"
"Mongo": {
"ConnectionString":"your-mongodb-connection-string",
"Database": "FileMetadataDB",
"Collection": "FileMetadata"
},
"Sql": {
"ConnectionString": "Your_SQL_Connection_String"
},
"AzureBlobConnectionString": "Your_Azure_Blob_Connection_String",
"AzureBlobContainer": "your-container-name",
"LogDirectory": "C:\\Logs\\FileUploader"
}
}
β Tip: Choose the StoreType based on where you want to store your file metadata (SQL Server or MongoDB).
2. Set up your Program.cs
var settings = builder.Configuration.GetSection("FileUploader").Get<FileUploaderSettings>();
// Add services to the container
builder.Services.AddControllers();
// Configure File Uploader with automatic setup
builder.Services.AddFileUploader(settings);
π‘ The AddFileUploader() method automatically reads your config and sets everything up.
3. Create your controller
Hereβs how to implement an endpoint that accepts files and uploads them:
[ApiController]
[Route("[controller]")]
[Consumes("multipart/form-data")]
public class FileUploadController : ControllerBase
{
private readonly IFileUploader _fileUploader;
public FileUploadController(IFileUploader fileUploader)
{
_fileUploader = fileUploader;
}
[HttpPost("upload")]
public async Task<IActionResult> Upload(
[FromForm] IFormFile file,
[FromQuery] string clientId)
{
await _fileUploader.UploadAsync(file, clientId, new Dictionary<string, object>
{
{ "status", "uploaded" },
{ "uploadedBy", "API" }
});
return Ok(new { Message = "Upload successful" });
}
}
π You can enrich the uploaded file with metadata using the dictionary passed to UploadAsync.
βοΈ Configuration Options
π FileUploaderSettings
Property | Type | Required | Description |
---|---|---|---|
StoreType |
enum | β Yes | MongoDB or SqlServer |
AzureBlobConnectionString |
string | β Yes | Azure Blob Storage connection string |
AzureBlobContainer |
string | β Yes | Name of the target container |
LogDirectory |
string | β No | Directory path for logs (default: system temp) |
π MongoDB Config (when StoreType = MongoDB)
Property | Type | Required | Description |
---|---|---|---|
ConnectionString |
string | β Yes | MongoDB connection |
Database |
string | β Yes | Database name |
Collection |
string | β Yes | Collection name |
π SQL Server Config (when StoreType = SqlServer)
Property | Type | Required | Description |
---|---|---|---|
ConnectionString |
string | β Yes | SQL Server connection |
π§± Database Schema Requirements
π MongoDB
Automatically creates the required collection. No schema setup needed.
π§± SQL Server
Create this table in your database:
CREATE TABLE FileMetadata (
Id NVARCHAR(255) PRIMARY KEY,
FileName NVARCHAR(255) NOT NULL,
ClientId NVARCHAR(255) NOT NULL,
BlobUri NVARCHAR(MAX) NOT NULL,
UploadDate DATETIME2 NOT NULL,
FileSize BIGINT NOT NULL,
MimeType NVARCHAR(100) NOT NULL,
SHA256 NVARCHAR(64) NOT NULL,
AdditionalData NVARCHAR(MAX) NULL
);
π Logging Configuration (NLog)
Add nlog.config
to your project.
Register NLog in Program.cs:
builder.Logging.AddNLog("nlog.config");
π€ Contributing
Contributions are welcome! Please:
- Code follows existing style
- New features include tests
- Documentation is updated
π Issues & Support
If you face any issues or need support, please reach out via email:
π§ info@threemsolutions.com
π License
This package is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net8.0
- Azure.Storage.Blobs (>= 12.24.0)
- Microsoft.AspNetCore.StaticFiles (>= 2.3.0)
- Microsoft.Data.SqlClient (>= 6.0.1)
- Microsoft.Extensions.Configuration (>= 9.0.7)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.7)
- Microsoft.Extensions.Logging (>= 9.0.4)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.7)
- MongoDB.Driver (>= 3.3.0)
- NLog (>= 5.4.0)
- NLog.Extensions.Logging (>= 5.4.0)
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.0 | 168 | 8/11/2025 |
Release Notes β Version 1.0.0
Release Date: 11-Aug-2025
Overview:
This is the first official release of Threem.File.UploaderKit, marking the start of our product journey.
This version includes the core features and a stable foundation for future updates.
Notes:
This is the first production-ready release. Users are encouraged to share feedback to help us improve future versions.