How to Install MinIO and Integrate It with Spring Boot for File Uploads

This guide introduces MinIO, an open‑source, S3‑compatible object storage written in Go, outlines its key features and deployment via Docker, and demonstrates step‑by‑step integration with Spring Boot to upload files through the MinIO SDK, including configuration, controller code, and testing.

macrozheng
macrozheng
macrozheng
How to Install MinIO and Integrate It with Spring Boot for File Uploads

Today I share a great open‑source distributed storage component MinIO, widely used.

What is MinIO?

MinIO is an open‑source object storage suite written in Go, licensed under Apache License v2.0. It is lightweight yet high‑performance and compatible with the Amazon S3 API, making it easy to integrate with NodeJS, Redis, MySQL and other applications.

Use Cases

MinIO can serve as a private‑cloud object storage service or as a gateway that seamlessly connects to Amazon S3 or Microsoft Azure.

Key Features

High Performance : read/write speeds up to 55Gb/s and 35Gb/s on standard hardware; supports objects from a few KB up to 5 TB.

Scalable : multiple MinIO clusters can form a federation with a global namespace across data centers.

Cloud‑Native : containerized, Kubernetes‑orchestrated, multi‑tenant.

S3 Compatibility : supports Amazon S3 v2/v4 API; usable via MinIO SDK, MinIO Client, AWS SDK, or AWS CLI.

SDK Support : Go, Java, Python SDKs.

Web UI : graphical management console.

Erasure Coding : uses erasure coding and checksums to protect against hardware errors; can survive loss of up to half the disks.

Installing MinIO with Docker

1. Pull the image

docker pull minio/minio

2. Run the container

docker run -p 9000:9000 -p 9001:9001 --name minio -d --restart=always \
-e "MINIO_ACCESS_KEY=admin" -e "MINIO_SECRET_KEY=admin" \
-v /home/data:/data -v /home/config:/root/.minio \
minio/minio server --console-address ":9000" --address ":9001" /data

The -p 9000 port serves the web console, while -p 9001 is the API port used by SDKs. MINIO_ACCESS_KEY and MINIO_SECRET_KEY set the console credentials.

3. Web UI Operations

After the container starts, open http://<your‑host>:9000/login, log in with the credentials above, create a bucket named test, and set its policy to public.

Integrating MinIO with Spring Boot

Although the UI allows manual uploads, files can also be uploaded programmatically via the MinIO SDK.

1. Add Maven dependency

<dependency>
    <groupId>io.minio</groupId>
    <artifactId>minio</artifactId>
    <version>8.2.1</version>
</dependency>

2. Configure properties (application.yml)

minio:
  endpoint: http://192.168.47.148
  port: 9001
  accessKey: HQGWFYLWGC6FVJ0CQFOG
  secretKey: pUGhAgQhZDxJaLmN3uz65YX7Bb3FyLdLglBvcCr1
  secure: false
  bucket-name: test
  image-size: 10485760
  file-size: 1073741824

3. Create upload controller

@RequestMapping("/minio")
@RestController
public class MinioController {

    @Autowired
    private MinioService minioService;

    @PostMapping("/upload")
    public String uploadFile(MultipartFile file, String bucketName) {
        String fileType = FileTypeUtils.getFileType(file);
        if (fileType != null) {
            return minioService.putObject(file, bucketName, fileType);
        }
        return "Unsupported file format. Please verify and retry.";
    }
}

4. Test the endpoint

Calling /minio/upload with an image returns the file’s URL, which can be opened directly in a browser. The uploaded object is visible in the MinIO console and can be shared with a 7‑day expiration link.

Conclusion

MinIO is a powerful open‑source object storage solution suitable for small projects or as a free image‑hosting service.

DockerSpring BootFile UploadMinIOObject StorageS3 Compatibility
macrozheng
Written by

macrozheng

Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.