Nexus.Upload 1.0.2

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

Nexus.Upload

Shared image-upload library for the Nexus microservices (user, catalog, commerce, auction, fulfillment, notification). It validates images and stores them through a pluggable storage provider, chosen automatically from configuration.

  • Local (development): saves files to a local directory, served via static files.
  • DigitalOcean Spaces (production): S3-compatible object storage via the AWS S3 SDK.

Install

dotnet add package Nexus.Upload

Register

using Nexus.Upload.src.Extensions;

builder.Services.AddNexusUpload(builder.Configuration); // reads the "UploadService" section

Serve locally-stored files (Local provider only):

app.UseStaticFiles(new StaticFileOptions
{
    FileProvider = new PhysicalFileProvider(Path.Combine(app.Environment.ContentRootPath, "uploads")),
    RequestPath = "/uploads"
});

Configuration

The provider is Spaces only when StorageType = "Spaces" and ASPNETCORE_ENVIRONMENT = "Production"; otherwise it falls back to Local.

Development (appsettings.json):

{
  "UploadService": {
    "StorageType": "Local",
    "Local": {
      "BaseDirectory": "uploads",
      "BaseUrl": "http://localhost:8080/uploads"
    }
  }
}

Production — supply secrets via environment variables, never commit them (UploadService__Spaces__AccessKey, ...):

{
  "UploadService": {
    "StorageType": "Spaces",
    "Spaces": {
      "AccessKey": "<spaces-access-key>",
      "SecretKey": "<spaces-secret-key>",
      "BucketName": "my-bucket",
      "Region": "sgp1",
      "Endpoint": "https://sgp1.digitaloceanspaces.com"
    }
  }
}

Spaces keys are created under DigitalOcean → API → Spaces Keys (not the DO API token) and need write access to the bucket. Objects are stored public-read so their URLs are directly viewable; the returned URL is https://{bucket}.{region}.digitaloceanspaces.com/{key}.

Usage

public sealed class AvatarController(UploadService uploadService)
{
    public async Task<IActionResult> Upload(IFormFile file)
    {
        using var ms = new MemoryStream();
        await file.CopyToAsync(ms);

        var result = await uploadService.UploadImageAsync(ms.ToArray(), new UploadOptions
        {
            Service   = "user",
            ImageType = "avatar",
            UserId    = currentUserId,
            FileName  = file.FileName,
            MimeType  = file.ContentType,
            Size      = file.Length
        });

        // result.Url, result.Key, result.Size
        return Ok(result);
    }
}

await uploadService.DeleteImageAsync(key);

Storage key format: {service}/{type}/{userId|shared}/{timestamp}-{filename}.

Image types & validation limits

Type Max size Allowed types Dimensions
avatar 2 MB jpeg, png, webp 100–2000 px
identity 5 MB jpeg, png, pdf min 600×400 px
product 10 MB jpeg, png, webp 300–4000 px
category 3 MB jpeg, png, webp min 500×300 px
proof 8 MB jpeg, png —
invoice 5 MB pdf, jpeg, png —
banner 5 MB jpeg, png, webp min 1200×300 px

Validation failures throw InvalidOperationException (message: Validation failed: ...).

Notes

  • Dimension validation uses SixLabors.ImageSharp. Its license is enforced at build time and only applies to projects that reference ImageSharp directly (i.e. this library). Consuming services reference the compiled package transitively and need no license file.
  • Only this library talks to storage; consumers depend on the IStorageProvider abstraction, so swapping providers requires no consumer code changes.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.2 120 7/15/2026
1.0.1 120 7/14/2026
1.0.0 114 7/14/2026