Granit.BlobStorage.Endpoints exposes a Minimal API for managing the full blob lifecycle:
initiate uploads (presigned URLs), confirm uploads (validation pipeline), generate download
URLs, delete blobs (crypto-shredding), and clean up orphans. All endpoints are protected
by the BlobStorage.Admin authorization policy with configurable role requirements.
Directory Granit.BlobStorage.Endpoints/ Granit.BlobStorage Granit.BlobStorage.EntityFrameworkCore
// In your application startup
app . MapBlobStorageEndpoints ();
app . MapBlobStorageEndpoints (opts =>
opts . RoutePrefix = " admin/blobs " ;
opts . RequiredRole = " storage-admin " ;
opts . TagName = " Storage " ;
Option Default Description RoutePrefix"blobs"Route prefix for all blob endpoints RequiredRole"granit-blobs-admin"Role required for the authorization policy TagName"BlobStorage"OpenAPI tag name for endpoint grouping
Configuration section: BlobStorageEndpoints.
Method Route Handler Description POST/uploadInitiateBlobUploadInitiate a direct-to-cloud upload, returns presigned URL POST/{id}/confirmConfirmBlobUploadConfirm upload completed, runs validation pipeline
Method Route Handler Description GET/{id}GetBlobDescriptorGet a blob descriptor by ID
Method Route Handler Description POST/{id}/download-urlGenerateBlobDownloadUrlGenerate a presigned download URL DELETE/{id}DeleteBlobDelete a blob (crypto-shredding, audit record retained) POST/cleanup-orphansCleanupOrphanedBlobsClean up orphaned blobs stuck in Pending/Uploading
When Granit.BlobStorage.EntityFrameworkCore is registered, a query endpoint is available:
Method Route Handler Description POST/queryQueryBlobDescriptorsFilter, sort, and paginate blob descriptors
DTO Direction Used by BlobUploadInitiateRequestInput POST upload BlobUploadInitiateResponseOutput POST upload (includes presigned URL) BlobConfirmUploadRequestInput POST confirm BlobConfirmUploadResponseOutput POST confirm (includes validation outcome) BlobDownloadUrlRequestInput POST download-url BlobDownloadUrlResponseOutput POST download-url (includes presigned URL) BlobDeleteRequestInput DELETE BlobDescriptorResponseOutput GET by ID BlobCleanupOrphansResponseOutput POST cleanup-orphans
All endpoints require the BlobStorage.Admin authorization policy. Granular permissions
are defined in BlobStoragePermissions:
Permission Description BlobStorage.Blobs.ViewView blob descriptors BlobStorage.Blobs.UploadUpload blobs BlobStorage.Blobs.DownloadDownload blobs BlobStorage.Blobs.DeleteDelete blobs BlobStorage.Blobs.ManageManage blobs (confirm uploads, cleanup orphans)
All request DTOs are automatically validated via FluentValidation through
MapGranitGroup(). Key rules:
Container names : lowercase alphanumeric with hyphens, max 128 chars
File names : non-empty, max 1024 chars
Content types : valid MIME format (type/subtype)
File size : must be positive
Deletion reason : max 500 chars (optional)