One store interface
IMediaStore offers UploadAsync, ListAsync by tenant, folder and media type, GetMetaAsync, GetAsync with a content stream, and DeleteAsync.
File uploads for ASP.NET Core in two lines.
MindAttic.Storage gives an ASP.NET Core app one upload API, a catalog row per file and a /_media/{uid} endpoint that streams safely with range support, so media handling stops being a weekend project.
What it is
Every app that accepts files ends up rebuilding the same plumbing: stream the upload, record it, serve it back with the right headers, and make sure nobody can upload a page that runs script on your origin. MindAttic.Storage packages that plumbing into two registration lines and one endpoint mapping.
Uploads stream through in a single pass that computes size and SHA-256 without buffering the file in memory, so gigabyte uploads are as safe as thumbnails. Small payloads stay inline in the database row; larger ones spill to disk under a stable GUID. Every file is referred to by that one uid, so the storage layout can always be rebuilt from the catalog.
Serving is careful by default. /_media/{uid} answers with Range processing, an ETag from the SHA-256, Last-Modified and nosniff. Images, video, audio, text and PDF display inline; HTML, SVG, XML, JavaScript and anything unparseable download as attachments under a sandboxing Content-Security-Policy.
It ships as two NuGet packages: MindAttic.Storage with the abstraction, EF Core model, local-disk store and endpoint, and MindAttic.Storage.Azure, an Azure Blob backend with a URL signer that is kept for existing consumers but frozen now that MindAttic runs on local storage.
Who it's for
Features
IMediaStore offers UploadAsync, ListAsync by tenant, folder and media type, GetMetaAsync, GetAsync with a content stream, and DeleteAsync.
Each MediaItem records uid, tenant, folder, file name, content type, size, SHA-256, dimensions, notes, timestamps and a row version, with indexes on uid, hash and tenant/folder/name.
Payloads up to 2 MB (configurable) stay in the row; larger ones spill to MediaRoot/{uid}/{file}. ThresholdSpillStream decides without knowing the length up front.
Size and SHA-256 are computed in flight during the copy, so even huge uploads are never buffered in memory.
/_media/{uid} streams with Range requests, ETag, Last-Modified and a private cache max-age, or redirects to a stored absolute URL.
HTML, SVG, XML, JavaScript and unparseable types download as attachments with Content-Security-Policy: sandbox; every response carries X-Content-Type-Options: nosniff.
Path segments and Windows-invalid characters are stripped the same way on every OS, while rows stored under the earlier rule keep resolving.
A cancelled or failed upload removes its spill file or partial blob. Deletes are soft, so a mistake is recoverable.
AddMediaAzure streams to a blob container and hands browsers signed, public or CDN URLs. It remains available for existing consumers and is frozen for new work.
How it works
Add MindAttic.Storage from your NuGet feed.
Apply MediaItemTypeConfiguration in your DbContext and add an EF Core migration for the MediaItem table.
Call AddMedia<AppDbContext>() and app.MapMediaEndpoints().
UploadAsync returns the item; link to it at /_media/{uid}.
Quick start
Local disk is the default store; the MediaItem column mapping targets SQL Server.
The full setup guide lives in the documentation.
// Program.cs
builder.Services.AddMedia<AppDbContext>(o => o.MediaRoot = @"D:\Data\media");
app.MapMediaEndpoints();
// anywhere you accept a file
var item = await store.UploadAsync(file.OpenReadStream(), file.FileName, file.ContentType, folder: "covers");
var url = $"/_media/{item.Uid}";Part of MindAttic
MindAttic.Storage is the family's media layer. Prose and IdeaCms store their uploads through it, and both reference the package with a Debug-only project reference to a sibling checkout, so local changes are picked up without repacking.
It was formerly MindAttic.Media; the API and public type names are unchanged, only the namespaces moved to MindAttic.Storage.
Status
Version 1.0.0 of both packages is published to the MindAttic NuGet feed and in use. With MindAttic's Azure resources retired, the remaining work is testing the local-disk DI wiring and documenting how consumers move off the frozen Azure backend.
Current milestone: MindAttic.Storage 1.x: the local-disk store complete, the Azure backend frozen.
Next step
Guides, reference and design notes are in the searchable MindAttic documentation. The source, issues and history are on GitHub.