askill
minio-storage

minio-storageSafety 100Repository

MinIO object storage integration for .NET applications. Use when working with file storage, S3-compatible storage, bucket operations, object uploads/downloads, presigned URLs, or configuring MinIO client in ASP.NET Core. Handles file persistence, media storage, document management, and any S3-compatible storage operations.

0 stars
1.2k downloads
Updated 2/14/2026

Package Files

Loading files...
SKILL.md

MinIO Storage

Overview

MinIO is an S3-compatible object storage server used in this project for file storage. This skill covers .NET SDK integration patterns for ASP.NET Core applications.

Setup

Install Package

dotnet add package Minio

DI Registration (Program.cs)

using Minio;

var builder = WebApplication.CreateBuilder(args);

// Option 1: Simple registration with credentials
builder.Services.AddMinio("accessKey", "secretKey");

// Option 2: Full configuration with custom endpoint
builder.Services.AddMinio(configureClient => configureClient
    .WithEndpoint("localhost:9000")  // or your MinIO server
    .WithCredentials("accessKey", "secretKey")
    .WithSSL(false)  // disable for local dev
    .Build());

Configuration (appsettings.json)

{
  "MinIO": {
    "Endpoint": "localhost:9000",
    "AccessKey": "minioadmin",
    "SecretKey": "minioadmin",
    "Secure": false
  }
}

Usage Patterns

Inject IMinioClient

public class FileService
{
    private readonly IMinioClient _minio;

    public FileService(IMinioClient minio) => _minio = minio;
}

Create Bucket

public async Task EnsureBucketExists(string bucketName)
{
    var exists = await _minio.BucketExistsAsync(
        new BucketExistsArgs().WithBucket(bucketName));
    
    if (!exists)
    {
        await _minio.MakeBucketAsync(
            new MakeBucketArgs().WithBucket(bucketName));
    }
}

Upload File

public async Task UploadFile(string bucket, string objectName, string filePath, string contentType)
{
    await _minio.PutObjectAsync(new PutObjectArgs()
        .WithBucket(bucket)
        .WithObject(objectName)
        .WithFileName(filePath)
        .WithContentType(contentType));
}

Upload from Stream

public async Task UploadStream(string bucket, string objectName, Stream data, long size, string contentType)
{
    await _minio.PutObjectAsync(new PutObjectArgs()
        .WithBucket(bucket)
        .WithObject(objectName)
        .WithStreamData(data)
        .WithObjectSize(size)
        .WithContentType(contentType));
}

Download File

public async Task<Stream> DownloadFile(string bucket, string objectName)
{
    var memoryStream = new MemoryStream();
    await _minio.GetObjectAsync(new GetObjectArgs()
        .WithBucket(bucket)
        .WithObject(objectName)
        .WithCallbackStream(stream => stream.CopyTo(memoryStream)));
    memoryStream.Position = 0;
    return memoryStream;
}

Generate Presigned URL

public async Task<string> GetPresignedUrl(string bucket, string objectName, int expirySeconds = 3600)
{
    return await _minio.PresignedGetObjectAsync(new PresignedGetObjectArgs()
        .WithBucket(bucket)
        .WithObject(objectName)
        .WithExpiry(expirySeconds));
}

Delete Object

public async Task DeleteObject(string bucket, string objectName)
{
    await _minio.RemoveObjectAsync(new RemoveObjectArgs()
        .WithBucket(bucket)
        .WithObject(objectName));
}

List Objects

public async Task<List<string>> ListObjects(string bucket, string prefix = "")
{
    var objects = new List<string>();
    await foreach (var item in _minio.ListObjectsEnumAsync(
        new ListObjectsArgs().WithBucket(bucket).WithPrefix(prefix)))
    {
        objects.Add(item.Key);
    }
    return objects;
}

API Controller Example

[ApiController]
[Route("api/[controller]")]
public class FilesController : ControllerBase
{
    private readonly IMinioClient _minio;
    private const string BucketName = "uploads";

    public FilesController(IMinioClient minio) => _minio = minio;

    [HttpPost("upload")]
    public async Task<IActionResult> Upload(IFormFile file)
    {
        await using var stream = file.OpenReadStream();
        var objectName = $"{Guid.NewGuid()}{Path.GetExtension(file.FileName)}";
        
        await _minio.PutObjectAsync(new PutObjectArgs()
            .WithBucket(BucketName)
            .WithObject(objectName)
            .WithStreamData(stream)
            .WithObjectSize(file.Length)
            .WithContentType(file.ContentType));

        return Ok(new { objectName });
    }

    [HttpGet("{objectName}/url")]
    public async Task<IActionResult> GetUrl(string objectName)
    {
        var url = await _minio.PresignedGetObjectAsync(
            new PresignedGetObjectArgs()
                .WithBucket(BucketName)
                .WithObject(objectName)
                .WithExpiry(3600));
        
        return Ok(new { url });
    }
}

Using IMinioClientFactory

For multiple configurations or per-request client creation:

public class MultiTenantStorageService
{
    private readonly IMinioClientFactory _factory;

    public MultiTenantStorageService(IMinioClientFactory factory) => _factory = factory;

    public async Task UploadToTenant(string tenantId, string objectName, Stream data)
    {
        var client = _factory.CreateClient(); // Optional: pass configure action
        // Use client...
    }
}

Common Args Classes

OperationArgs ClassKey Methods
Bucket existsBucketExistsArgs.WithBucket()
Make bucketMakeBucketArgs.WithBucket(), .WithLocation()
UploadPutObjectArgs.WithBucket(), .WithObject(), .WithFileName() / .WithStreamData()
DownloadGetObjectArgs.WithBucket(), .WithObject(), .WithCallbackStream()
DeleteRemoveObjectArgs.WithBucket(), .WithObject()
Presigned GETPresignedGetObjectArgs.WithBucket(), .WithObject(), .WithExpiry()
Presigned PUTPresignedPutObjectArgs.WithBucket(), .WithObject(), .WithExpiry()
List objectsListObjectsArgs.WithBucket(), .WithPrefix(), .WithRecursive()

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

95/100Analyzed 2/19/2026

Excellent skill document for MinIO storage integration in .NET. Provides comprehensive setup instructions, configuration examples, and detailed code patterns for all major operations (bucket management, file upload/download, presigned URLs, object listing/deletion). Includes practical API controller example and IMinioClientFactory pattern for multi-tenant scenarios. Well-structured with clear headings, consistent code formatting, and a helpful reference table. The description includes clear 'when to use' trigger. Slightly odd tags (api, ci-cd) but content quality is high. Located in dedicated skills folder per R10. Strong bonus from R3 (clear use case), R5 (structured steps), and R11 (high-density technical reference). Not internal-only despite .opencode path - content is general and reusable."

100
95
90
95
95

Metadata

Licenseunknown
Version-
Updated2/14/2026
Publishererloon

Tags

apici-cd