How to Set Up kkFileView for Instant File Preview with Docker and SpringBoot
This guide walks you through installing kkFileView on Windows and Linux, integrating it with MinIO for online file preview, configuring Docker containers, and customizing settings such as watermarks, providing step‑by‑step instructions and code snippets for a seamless preview service.
In a previous article we used MinIO for object storage; now we introduce kkFileView, a SpringBoot‑based service that enables online preview of various file formats.
kkFileView Overview
kkFileView is an open‑source file preview solution (5.7k+ stars on GitHub) built with SpringBoot, supporting documents like docx, xlsx, pptx, pdf, txt, zip, images, video, audio, etc.
Installation
Windows
Download the latest release package from the official repository.
Extract it to a directory and run
startup.batin the
binfolder.
To modify configuration, edit the
application.propertiesfile under the
configdirectory.
Linux
Pull the Docker image:
<code>docker pull keking/kkfileview</code>Run the container on port 8012:
<code>docker run -p 8012:8012 --name kkfileview \
-d keking/kkfileview</code>Access the test page at
http://<your_ip>:8012.
Usage
After storing files in MinIO (e.g., in a bucket named
preview), obtain the file URL, base64‑encode it, and call the preview endpoint:
<code>http://<your_ip>:8012/onlinePreview?url=base64Encode($url)</code>Examples include previewing images, Word documents (converted to PDF or JPG), PPT, PDF, Excel, Markdown, and compressed files.
Configuration
Configuration files reside in the
configdirectory. To edit them from a Docker container:
<code>docker cp kkfileview:/opt/kkFileView-3.5.1/config /mydata/kkFileView/</code>Mount the configuration, file, and log directories when running the container:
<code>docker run -p 8012:8012 --name kkfileview \
-v /mydata/kkFileView/config:/opt/kkFileView-3.5.1/config \
-v /mydata/kkFileView/file:/opt/kkFileView-3.5.1/file \
-v /mydata/kkFileView/log:/opt/kkFileView-3.5.1/log \
-d keking/kkfileview</code>To add a watermark, set the
watermark.txtproperty in
application.properties:
<code># Watermark content
# To disable, set empty: watermark.txt = ${WATERMARK_TXT:}
watermark.txt = ${WATERMARK_TXT:macrozheng}</code>Summary
kkFileView provides a simple way to preview Office documents, images, videos, and more; it converts Word and PPT files to PDF or JPG for display, making it a versatile solution for building an all‑in‑one online file preview 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.