How to Preview Any File Online with Spring Boot, MinIO, and kkFileView
This tutorial shows how to set up MinIO and the open‑source kkFileView tool using Docker, configure a storage bucket, and generate preview URLs so that any file type—images, Word, PDF, PPT, markdown, Excel, or archives—can be viewed directly in a web browser without writing additional code.
kkFileView Overview
kkFileView is an open‑source online preview project built on Spring Boot, currently with over 21k stars on Gitee. It is easy to deploy and supports preview of almost all common file formats.
Installation
Using Docker to install MinIO and kkFileView is very convenient.
MinIO
Download the MinIO Docker image:
<code>docker pull minio/minio</code>Run the MinIO container, exposing the console on port
9001and the service on port
9090:
<code>docker run -p 9090:9000 -p 9001:9001 --name minio \
-v /mydata/minio/data:/data \
-e MINIO_ROOT_USER=minioadmin \
-e MINIO_ROOT_PASSWORD=minioadmin \
-d minio/minio server /data --console-address ":9001"</code>Access the MinIO console at
http://192.168.3.101:9001using the default credentials
minioadmin:minioadmin.
kkFileView
Download the kkFileView Docker image:
<code>docker pull keking/kkfileview</code>Run the kkFileView container on port
8012:
<code>docker run -p 8012:8012 --name kkfileview \
-d keking/kkfileview</code>Open the kkFileView test page at
http://192.168.3.101:8012.
Usage
Now we will demonstrate how to use MinIO and kkFileView together.
Preparation
Create a bucket named
previewin MinIO.
Set the bucket's access policy to
Publicfor external access.
Upload files to the bucket.
Files stored in MinIO can be accessed via
http://192.168.3.101:9090/{bucketName}/{fileName}. For example, the file
avatar.pngin the
previewbucket is reachable at
http://192.168.3.101:9090/preview/avatar.png.
File Preview
We now explain how to preview files from MinIO using kkFileView.
Image
Enter the file name on the kkFileView test page to obtain a preview link.
Preview URL format (base64‑encoded):
<code>http://192.168.3.101:8012/onlinePreview?url=base64Encode($url)</code>Word
Preview a Word document directly in the browser.
Preview a PDF document directly in the browser.
PPT
Preview a PowerPoint presentation directly in the browser.
Markdown
Preview a markdown file directly in the browser.
Excel
Preview an Excel file directly in the browser.
Compressed Files
Compressed archives can be opened and their internal files previewed.
Conclusion
This guide demonstrated how to achieve online preview of any file type by combining Spring Boot, MinIO, and kkFileView, without writing additional code. You can apply this setup in projects that require file preview functionality.
Project Repository
https://gitee.com/kekingcn/file-online-preview
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.