Nexus.Upload
1.0.2
dotnet add package Nexus.Upload --version 1.0.2
NuGet\Install-Package Nexus.Upload -Version 1.0.2
<PackageReference Include="Nexus.Upload" Version="1.0.2" />
<PackageVersion Include="Nexus.Upload" Version="1.0.2" />
<PackageReference Include="Nexus.Upload" />
paket add Nexus.Upload --version 1.0.2
#r "nuget: Nexus.Upload, 1.0.2"
#:package Nexus.Upload@1.0.2
#addin nuget:?package=Nexus.Upload&version=1.0.2
#tool nuget:?package=Nexus.Upload&version=1.0.2
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
IStorageProviderabstraction, so swapping providers requires no consumer code changes.
| Product | Versions 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. |
-
net10.0
- AWSSDK.S3 (>= 3.7.416)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.9)
- SixLabors.ImageSharp (>= 4.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.