Skip to content

File preview tool based on Spring Boot. 基于springboot的文件预览工具

License

Notifications You must be signed in to change notification settings

weimin96/file-viewer-tool

Repository files navigation

file-viewer-tool

Java CI GitHub Release Maven Central Version GitHub repo size License Last Commit GitHub commit activity

README: English | 中文

Introduction

Universal tool for online document preview. Based on the Spring Boot framework and SPI pluggable mode, it can be quickly integrated into Spring Boot projects to achieve file online preview functionality.

Supported formats:

  • Images: jpg、jpeg、png、gif
  • Documents: doc、docx、pdf、xls、xlsx、csv
  • Text: txt、json、htmL
  • Video: mp4、avi
  • CAD: dwg、dxf

Supported components:

components Name Description
file-viewer-core Core package comprising file preview entry points and generic file handling logic.(txt、json、csv、htmL、pdf、jpg、jpeg、png、gif、mp4、avi)
file-viewer-cad CAD format processing module (dwg、dxf)
file-viewer-poi document format processing module (doc、docx、xls、xlsx)

You can individually import each module according to your needs, or you can import all modules collectively by using the file-viewer-all package.

Getting Started

Introduce dependency

Mode one:To import all dependencies

<dependency>
    <groupId>io.github.weimin96</groupId>
    <artifactId>file-viewer-all</artifactId>
    <version>${lastVersion}</version>
</dependency>

Mode two:Separate introduction

core module(must)

<dependency>
    <groupId>io.github.weimin96</groupId>
    <artifactId>file-viewer-core</artifactId>
    <version>${lastVersion}</version>
</dependency>

cad module

<dependency>
    <groupId>io.github.weimin96</groupId>
    <artifactId>file-viewer-cad</artifactId>
    <version>${lastVersion}</version>
</dependency>

poi module

<dependency>
    <groupId>io.github.weimin96</groupId>
    <artifactId>file-viewer-poi</artifactId>
    <version>${lastVersion}</version>
</dependency>

Usage

@GetMapping(value = "/preview")
public void preview(String path) {
    File file = new File(path);
    ViewerContext.preview(file);
}

All supported methods

1、Write HttpServletResponse through MultipartFile

ViewerContext.preview(MultipartFile multipartFile);

2、Write HttpServletResponse through InputStream

ViewerContext.preview(InputStream inputStream, String filenameOrExtension);

2、Write HttpServletResponse through File

ViewerContext.preview(File file) ;

About

File preview tool based on Spring Boot. 基于springboot的文件预览工具

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages