Backend Development 7 min read

How to Build a Powerful File Preview Service with kkFileView and SpringBoot

This guide walks you through setting up kkFileView—a SpringBoot‑based file preview tool—on Windows or Linux (Docker), configuring it to work with MinIO, and using it to preview a wide range of document, image, video, and archive formats via simple base64‑encoded URLs.

macrozheng
macrozheng
macrozheng
How to Build a Powerful File Preview Service with kkFileView and SpringBoot

kkFileView Overview

kkFileView is an open‑source SpringBoot application (over 5.7k stars on GitHub) that provides online preview for common office documents such as DOCX, XLSX, PPTX, PDF, TXT, ZIP, images, videos, and audio files.

Installation

Windows

Download the latest release package from the official repository.

Extract it to a directory and run

bin/startup.bat

to start the service.

To modify configuration, edit

config/application.properties

inside the project.

Linux (Docker)

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>

Usage with MinIO

Store files in a MinIO bucket (e.g.,

preview

) using a client such as S3 Browser, then set the bucket policy to allow anonymous access.

To preview a file, call the online preview endpoint with a base64‑encoded file URL:

<code>http://<span>$host</span>:8012/onlinePreview?url=base64Encode($url)</code>

Examples include previewing images, Word documents (converted to PDF or JPG), PPT files, PDFs, Excel sheets, Markdown text, and ZIP archives.

Configuration

The main configuration resides in

config/application.properties

. To customize Docker settings, copy the config directory from the container:

<code>docker cp kkfileview:/opt/kkFileView-3.5.1/config /mydata/kkFileView/config</code>

Then mount the config, 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

watermark.txt=${WATERMARK_TXT:macrozheng}

in the properties file.

Summary

kkFileView provides a simple, out‑of‑the‑box solution for online preview of office documents, images, videos, and archives. By converting files to PDF or JPG, it meets most preview needs without complex setup, making it ideal for building a universal file preview service.

Reference

Official documentation: https://kkfileview.keking.cn/zh-cn/index.html

DockerSpringBootMinIOFile Previewonline previewkkFileView
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

login 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.