A guide to using MinIO as an object storage solution in .NET applications.
MinIO is a high-performance, S3-compatible object storage service that is perfect for cloud-native applications. In this guide, we will explore how to integrate MinIO with .NET applications, providing you with the ability to create, delete, and manage buckets and files seamlessly.
Before diving into code, ensure that you have MinIO installed and running. You can use the following Dockerfile to set up MinIO with a client for managing buckets and policies:
# Use the official MinIO image
FROM minio/minio:latest
# Set the MinIO data directory (this is where your data will be stored)
ENV MINIO_VOLUMES="/data"
# Set MinIO access and secret keys
ENV MINIO_ROOT_USER=<your-access-key> \
MINIO_ROOT_PASSWORD=<your-secret-key>
# Expose MinIO API (default port 9000) and console (port 9001)
EXPOSE 9000 9001
# Download MinIO Client (mc) for managing buckets and policies using curl
RUN curl -O https://dl.min.io/client/mc/release/linux-amd64/mc \
&& chmod +x mc \
&& mv mc /usr/local/bin/
# Copy the script to create buckets and set policies
COPY create-buckets.sh /usr/local/bin/create-buckets.sh
RUN chmod +x /usr/local/bin/create-buckets.sh
# Use bash to handle the script execution
ENTRYPOINT ["bash", "-c", "/usr/local/bin/create-buckets.sh & minio server /data --console-address :9001"]
version: '3.8'
services:
minio:
build:
context: .
dockerfile: Dockerfile
ports:
- "9000:9000" # MinIO API
- "9001:9001" # MinIO Console
environment:
MINIO_ROOT_USER: <your-access-key>
MINIO_ROOT_PASSWORD: <your-secret-key>
volumes:
- minio-data:/data # Persistent data storage
volumes:
minio-data:
docker-compose up --build
For the complete code and implementation, you can visit the public repository: MinioServerConsoleApp.