Skip to main content
Login Register
Code2night
  • Home
  • Blog Archive
  • Learn
    • Tutorials
    • Videos
  • Interview Q&A
  • Resources
    • Cheatsheets
    • Tech Comparisons
  • Languages
    • Angular Angular js ASP.NET Asp.net Core ASP.NET Core, C# ASP.NET MVC ASP.NET Web Forms C C# C#, ASP.NET Core, Dapper
      C#, ASP.NET Core, Dapper, Entity Framework DotNet General Web Development HTML, CSS HTML/CSS Java JavaScript JavaScript, HTML, CSS JavaScript, Node.js Node.js
      Python Python 3.11, Pandas, SQL Python 3.11, SQL Python 3.11, SQLAlchemy Python 3.11, SQLAlchemy, SQL Python 3.11, SQLite React Security SQL Server TypeScript
  • Post Blog
  • Tools
    • Beautifiers
      JSON Beautifier HTML Beautifier XML Beautifier CSS Beautifier JS Beautifier SQL Formatter
      Dev Utilities
      JWT Decoder Regex Tester Diff Checker Cron Explainer String Escape Hash Generator Password Generator
      Converters
      Base64 Encode/Decode URL Encoder/Decoder JSON to CSV CSV to JSON JSON to TypeScript Markdown to HTML Number Base Converter Timestamp Converter Case Converter
      Generators
      UUID / GUID Generator Lorem Ipsum QR Code Generator Meta Tag Generator
      Image Tools
      Image Converter Image Resizer Image Compressor Image to Base64 PNG to ICO Background Remover Color Picker
      Text & Content
      Word Counter PDF Editor
      SEO & Web
      SEO Analyzer URL Checker World Clock
  1. Home
  2. Blog
  3. ASP.NET Core
  4. Integrating MinIO Object Storage in ASP.NET Core: A Self-Hosted S3 Alternative

Integrating MinIO Object Storage in ASP.NET Core: A Self-Hosted S3 Alternative

Date- May 03,2026 94
minio object storage

Overview

MinIO is an open-source object storage server that provides an Amazon S3-compatible API, allowing developers to build scalable storage solutions on their own infrastructure. It exists to solve the need for reliable, high-performance storage that is also cost-effective and easy to manage. In an era where data is rapidly growing, having control over your storage solution becomes crucial for many businesses.

Real-world use cases for MinIO range from serving static assets for web applications to providing a backend for data analytics pipelines. Companies often use MinIO to store images, videos, backups, and other unstructured data while taking advantage of its compatibility with existing S3 tools and libraries.

Prerequisites

  • ASP.NET Core: Familiarity with ASP.NET Core framework and its concepts.
  • Docker: Understanding of Docker for running MinIO in a containerized environment.
  • NuGet Packages: Basic knowledge of managing NuGet packages in an ASP.NET Core project.
  • C#: Proficiency in C# to write and understand the provided code examples.

Setting Up MinIO

Before integrating MinIO with ASP.NET Core, you need to set up the MinIO server. This can be done easily using Docker, which ensures a consistent environment across different setups. Running MinIO in a container allows you to quickly start and stop the service as needed.

docker run -p 9000:9000 -p 9001:9001 \
  -e "MINIO_ACCESS_KEY=minioadmin" \
  -e "MINIO_SECRET_KEY=minioadmin" \
  minio/minio server /data --console-address ":9001"

This command runs MinIO on ports 9000 and 9001, with the access and secret keys set to minioadmin. The data will be stored in the /data directory.

Accessing the MinIO Console

Once the container is running, you can access the MinIO console by navigating to http://localhost:9001. Log in using the credentials set earlier. This console provides a web interface to manage buckets and objects, making it easier to interact with your storage solution.

Integrating MinIO with ASP.NET Core

The next step is to integrate MinIO into your ASP.NET Core application using the Minio.Client library. This library provides a simple and efficient way to interact with MinIO or any S3-compatible storage.

dotnet add package Minio

This command installs the Minio client library in your ASP.NET Core project. After installation, you can configure the MinIO client in your application.

Configuring the MinIO Client

The MinIO client can be configured in the Startup.cs file of your ASP.NET Core application. You will need to set the endpoint, access key, and secret key for the MinIO server.

public void ConfigureServices(IServiceCollection services)
{
    services.AddSingleton(new MinioClient()
        .WithEndpoint("localhost", 9000)
        .WithCredentials("minioadmin", "minioadmin")
        .Build());
}

This code registers the MinIO client as a singleton service in the ASP.NET Core dependency injection container. The WithEndpoint method specifies the server's address, while WithCredentials sets the access and secret keys.

Uploading Files to MinIO

Uploading files to MinIO is a straightforward process once the client is set up. You need to create a bucket first if it doesn't already exist, and then you can upload files to that bucket.

public async Task UploadFileAsync(string bucketName, string objectName, string filePath)
{
    var minioClient = new MinioClient();
    await minioClient.MakeBucketAsync(new MakeBucketOptions(bucketName));
    await minioClient.PutObjectAsync(bucketName, objectName, filePath, null);
}

The UploadFileAsync method creates a new bucket if it does not exist and uploads the specified file to the MinIO server. The MakeBucketAsync method ensures that the bucket is created before uploading the file.

Handling Errors During Upload

It's essential to handle potential errors during file upload. For instance, if the bucket already exists, the MakeBucketAsync method will throw an exception. You can catch this exception and proceed with the upload.

try
{
    await minioClient.MakeBucketAsync(new MakeBucketOptions(bucketName));
}
catch (MinioException e) when (e.StatusCode == 409)
{
    // Bucket already exists, proceed with upload
}
await minioClient.PutObjectAsync(bucketName, objectName, filePath, null);

Downloading Files from MinIO

Downloading files from MinIO is similar to uploading files. You can retrieve an object from a specified bucket using the MinIO client.

public async Task DownloadFileAsync(string bucketName, string objectName, string destinationPath)
{
    var minioClient = new MinioClient();
    await minioClient.GetObjectAsync(bucketName, objectName, destinationPath);
}

The DownloadFileAsync method downloads the specified object from the given bucket to the local file system. It uses the GetObjectAsync method of the MinIO client.

Progress Tracking During Download

Tracking the download progress can enhance user experience, especially for larger files. You can achieve this by using a callback function that reports progress.

await minioClient.GetObjectAsync(bucketName, objectName, destinationPath, (progress) =>
{
    Console.WriteLine($"Downloaded {progress} bytes");
});

Edge Cases & Gotchas

When working with MinIO, there are several pitfalls to be aware of. One common issue arises from not properly handling exceptions, especially when making network calls.

// Incorrect approach
try
{
    await minioClient.PutObjectAsync(bucketName, objectName, filePath, null);
}
catch
{
    // Swallowing exceptions without logging
}

This approach fails to log the error, making it difficult to diagnose issues. Instead, always log exceptions for better debugging.

// Correct approach
try
{
    await minioClient.PutObjectAsync(bucketName, objectName, filePath, null);
}
catch (MinioException e)
{
    Console.Error.WriteLine(e.Message);
}

Performance & Best Practices

To optimize performance when using MinIO, consider the following best practices:

  • Batch Operations: For multiple uploads or downloads, batch your operations to reduce network calls.
  • Use Multipart Uploads: For large files, use multipart uploads to improve reliability and speed.
  • Monitor Bucket Policies: Regularly review and adjust bucket policies to ensure they meet security requirements without impacting performance.

Real-World Scenario: Building a File Upload Service

Let’s implement a simple file upload service in ASP.NET Core that utilizes MinIO for storage. This service will allow users to upload files and retrieve them later.

public class FileUploadController : ControllerBase
{
    private readonly IMinioClient _minioClient;

    public FileUploadController(IMinioClient minioClient)
    {
        _minioClient = minioClient;
    }

    [HttpPost("upload")]
    public async Task Upload(IFormFile file)
    {
        var bucketName = "uploads";
        var objectName = file.FileName;
        using (var stream = file.OpenReadStream())
        {
            await _minioClient.PutObjectAsync(bucketName, objectName, stream, file.Length);
        }
        return Ok();
    }

    [HttpGet("download/{objectName}")]
    public async Task Download(string objectName)
    {
        var bucketName = "uploads";
        var stream = new MemoryStream();
        await _minioClient.GetObjectAsync(bucketName, objectName, stream);
        stream.Position = 0;
        return File(stream, "application/octet-stream", objectName);
    }
}

The FileUploadController class provides two endpoints: one for uploading files and one for downloading them. The upload endpoint takes an IFormFile and stores it in the MinIO bucket, while the download endpoint retrieves the file and sends it back to the client.

Conclusion

  • MinIO provides a powerful, self-hosted alternative to Amazon S3 for object storage.
  • Integrating MinIO with ASP.NET Core is straightforward with the Minio.Client library.
  • Always handle exceptions and log errors to debug issues effectively.
  • Utilize best practices for performance optimization when working with object storage.
  • Real-world scenarios demonstrate practical implementations of MinIO in ASP.NET Core applications.

S
Shubham Saini
Programming author at Code2Night — sharing tutorials on ASP.NET, C#, and more.
View all posts →

Related Articles

Integrating Backblaze B2 Cloud Storage with ASP.NET Core Applications
May 03, 2026
Azure Blob Storage Integration in ASP.NET Core - File Management at Scale
Apr 20, 2026
Building a File Upload Feature Using Google Drive in ASP.NET Core
Apr 18, 2026
Integrating Google Drive API with ASP.NET Core: A Step-by-Step Guide
Apr 17, 2026
Previous in ASP.NET Core
Integrating Backblaze B2 Cloud Storage with ASP.NET Core Applicat…
Next in ASP.NET Core
Integrating OpenAI GPT-4 API in ASP.NET Core: Chat, Completions, …
Buy me a pizza

Comments

🔥 Trending This Month

  • 1
    Complete Guide to C++ Classes: Explained with Examples 4,212 views
  • 2
    Implementing an End-to-End CI/CD Pipeline for ASP.NET Core… 366 views
  • 3
    Create Database and CRUD operation 3,388 views
  • 4
    Mastering TypeScript Utility Types: Partial, Required, Rea… 675 views
  • 5
    Responsive Slick Slider 23,373 views
  • 6
    Integrating Azure Cognitive Search into ASP.NET Core Appli… 156 views
  • 7
    Integrating Anthropic Claude API in ASP.NET Core for AI Ch… 141 views

On this page

🎯

Interview Prep

Ace your ASP.NET Core interview with curated Q&As for all levels.

View ASP.NET Core Interview Q&As

More in ASP.NET Core

  • How to Encrypt and Decrypt Password in Asp.Net 26191 views
  • Exception Handling Asp.Net Core 20938 views
  • HTTP Error 500.31 Failed to load ASP NET Core runtime 20391 views
  • How to implement Paypal in Asp.Net Core 19753 views
  • Task Scheduler in Asp.Net core 17705 views
View all ASP.NET Core posts →

Tags

AspNet C# programming AspNet MVC c programming AspNet Core C software development tutorial MVC memory management Paypal coding coding best practices data structures programming tutorial tutorials object oriented programming Slick Slider StripeNet
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1770
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, Haryana, India
info@code2night.com
Quick Links
  • Home
  • Blog Archive
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
  • SEO Analyzer
Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • SQL Formatter
  • Diff Checker
  • Regex Tester
  • Markdown to HTML
  • Word Counter
More Tools
  • Password Generator
  • QR Code Generator
  • Hash Generator
  • Base64 Encoder
  • JWT Decoder
  • UUID Generator
  • Image Converter
  • PNG to ICO
  • SEO Analyzer
By Language
  • Angular
  • Angular js
  • ASP.NET
  • Asp.net Core
  • ASP.NET Core, C#
  • ASP.NET MVC
  • ASP.NET Web Forms
  • C
  • C#
  • C#, ASP.NET Core, Dapper
  • C#, ASP.NET Core, Dapper, Entity Framework
  • DotNet
  • General Web Development
  • HTML, CSS
  • HTML/CSS
  • Java
  • JavaScript
  • JavaScript, HTML, CSS
  • JavaScript, Node.js
  • Node.js
  • Python
  • Python 3.11, Pandas, SQL
  • Python 3.11, SQL
  • Python 3.11, SQLAlchemy
  • Python 3.11, SQLAlchemy, SQL
  • Python 3.11, SQLite
  • React
  • Security
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Made with for developers  |  Privacy  ·  Terms
Translate Page
We use cookies to improve your experience and analyze site traffic. By clicking Accept, you consent to our use of cookies. Privacy Policy
Accessibility
Text size
High contrast
Grayscale
Dyslexia font
Highlight links
Pause animations
Large cursor