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
                    
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="Threem.File.UploaderKit" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Threem.File.UploaderKit" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Threem.File.UploaderKit" />
                    
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 Threem.File.UploaderKit --version 1.0.0
                    
#r "nuget: Threem.File.UploaderKit, 1.0.0"
                    
#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 Threem.File.UploaderKit@1.0.0
                    
#: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=Threem.File.UploaderKit&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Threem.File.UploaderKit&version=1.0.0
                    
Install as a Cake Tool

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 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. 
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.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.