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.
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/minio2. 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" /dataThe -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: 10737418243. 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.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
