mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-04-28 11:06:43 +00:00
Compare commits
99 Commits
dependabot
...
v4.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb12eb0695 | ||
|
|
d78351f72c | ||
|
|
af752cfa13 | ||
|
|
f0dc845825 | ||
|
|
5ecb5f667d | ||
|
|
3dcd183171 | ||
|
|
167189d4e4 | ||
|
|
d6c083fb5b | ||
|
|
1dd59cf764 | ||
|
|
e7930a2442 | ||
|
|
1261e6aa03 | ||
|
|
3abcfe90bc | ||
|
|
cf336781d8 | ||
|
|
4c0aa3cfc3 | ||
|
|
0a1fb6d983 | ||
|
|
99b1f83e50 | ||
|
|
4db74d0931 | ||
|
|
9860df9b6d | ||
|
|
4c225b030d | ||
|
|
9e5b9d4889 | ||
|
|
e9c4e134c6 | ||
|
|
5704a4182e | ||
|
|
489bdfbc01 | ||
|
|
53a840af4b | ||
|
|
8c8d596c43 | ||
|
|
a3f91641dd | ||
|
|
f5754be9ff | ||
|
|
12f40b831f | ||
|
|
859feff328 | ||
|
|
bba44ca057 | ||
|
|
5134f7a121 | ||
|
|
b366d0b464 | ||
|
|
e3fb1d7c15 | ||
|
|
883b45f201 | ||
|
|
8fb32e4f73 | ||
|
|
764ea702d0 | ||
|
|
b225cebc95 | ||
|
|
106036d989 | ||
|
|
026656711d | ||
|
|
35a8c4a5a6 | ||
|
|
86960e3813 | ||
|
|
b099d52520 | ||
|
|
6efe15788c | ||
|
|
3e43c2f9d0 | ||
|
|
f1b949865f | ||
|
|
ab439a17a3 | ||
|
|
dd65564af6 | ||
|
|
acffcbfe98 | ||
|
|
04703aa03c | ||
|
|
584e6b2c77 | ||
|
|
82f6d3565f | ||
|
|
8c68834e17 | ||
|
|
ba7b6eed4a | ||
|
|
051ad0f4ea | ||
|
|
05935c29e1 | ||
|
|
6a2735ec3d | ||
|
|
8bc53f76eb | ||
|
|
48f6a507dc | ||
|
|
20f328906c | ||
|
|
4d1e2eb9c6 | ||
|
|
97542b06fa | ||
|
|
0c93c7e4b6 | ||
|
|
56d9906c74 | ||
|
|
5cfe37433f | ||
|
|
45ebef3b74 | ||
|
|
2ed294bd65 | ||
|
|
91f3348a2f | ||
|
|
d424de5e9a | ||
|
|
6387ac21c9 | ||
|
|
6dce47e47f | ||
|
|
b7760ab42a | ||
|
|
e0405bc5f6 | ||
|
|
14151a6c46 | ||
|
|
00555d3544 | ||
|
|
7b2adc3979 | ||
|
|
0a5fc1e4a8 | ||
|
|
304d974b38 | ||
|
|
6792a7afa7 | ||
|
|
ded297de59 | ||
|
|
f616678d83 | ||
|
|
e10273dcdd | ||
|
|
343269670c | ||
|
|
8af157b848 | ||
|
|
9d65c999e5 | ||
|
|
4fe0d0edc9 | ||
|
|
b1aab27338 | ||
|
|
727e9ae9ed | ||
|
|
dc9df5d760 | ||
|
|
b7de791658 | ||
|
|
82c7b59650 | ||
|
|
e0b9d8f476 | ||
|
|
db2ed3a555 | ||
|
|
6efc375066 | ||
|
|
9a4c864490 | ||
|
|
a3081ef4a9 | ||
|
|
43374e02bd | ||
|
|
fb8a19469b | ||
|
|
f2d5f4a86c | ||
|
|
2177aed64f |
24
.github/workflows/maven.yml
vendored
Normal file
24
.github/workflows/maven.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
||||||
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
||||||
|
|
||||||
|
name: Java CI with Maven
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up JDK 8
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
java-version: '8'
|
||||||
|
distribution: 'adopt'
|
||||||
|
cache: maven
|
||||||
|
- name: Build with Maven
|
||||||
|
run: mvn -B package --file pom.xml
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -25,6 +25,7 @@ nbdist/
|
|||||||
|
|
||||||
### VS Code ###
|
### VS Code ###
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
server/src/main/cache/
|
server/src/main/cache/
|
||||||
server/src/main/file/
|
server/src/main/file/
|
||||||
|
|||||||
31
.workflow/MasterPipeline.yml
Normal file
31
.workflow/MasterPipeline.yml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
version: '1.0'
|
||||||
|
name: master-pipeline
|
||||||
|
displayName: MasterPipeline
|
||||||
|
stages:
|
||||||
|
- stage:
|
||||||
|
name: compile
|
||||||
|
displayName: 编译
|
||||||
|
steps:
|
||||||
|
- step: build@maven
|
||||||
|
name: build_maven
|
||||||
|
displayName: Maven 构建
|
||||||
|
# 支持6、7、8、9、10、11六个版本
|
||||||
|
jdkVersion: 8
|
||||||
|
# 支持2.2.1、3.2.5、3.3.9、3.5.2、3.5.3、3.5.4、3.6.1、3.6.3八个版本
|
||||||
|
mavenVersion: 3.6.3
|
||||||
|
# 构建命令
|
||||||
|
commands:
|
||||||
|
- mvn -B clean package -Dmaven.test.skip=true
|
||||||
|
# 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除
|
||||||
|
artifacts:
|
||||||
|
# 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
|
||||||
|
- name: BUILD_ARTIFACT
|
||||||
|
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径,如通常jar包在target目录下。当前目录为代码库根目录
|
||||||
|
path:
|
||||||
|
- ./server/target/kkFileView-*.tar.gz
|
||||||
|
- ./server/target/kkFileView-*.zip
|
||||||
|
triggers:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
include:
|
||||||
|
- master
|
||||||
42
Dockerfile
42
Dockerfile
@@ -1,41 +1,5 @@
|
|||||||
FROM ubuntu:20.04
|
FROM keking/kkfileview-jdk:4.1.1
|
||||||
MAINTAINER chenjh "842761733@qq.com"
|
MAINTAINER chenjh "842761733@qq.com"
|
||||||
ADD server/target/kkFileView-*.tar.gz /opt/
|
ADD server/target/kkFileView-*.tar.gz /opt/
|
||||||
COPY fonts/* /usr/share/fonts/chinese/
|
ENV KKFILEVIEW_BIN_FOLDER /opt/kkFileView-4.1.0/bin
|
||||||
RUN echo "deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse\ndeb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse\ndeb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse\ndeb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse\ndeb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse\ndeb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse\ndeb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse\ndeb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse\ndeb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse\ndeb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse" > /etc/apt/sources.list &&\
|
ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-Dspring.config.location=/opt/kkFileView-4.1.0/config/application.properties","-jar","/opt/kkFileView-4.1.0/bin/kkFileView-4.1.0.jar"]
|
||||||
apt-get clean && apt-get update &&\
|
|
||||||
apt-get install -y locales && apt-get install -y language-pack-zh-hans &&\
|
|
||||||
localedef -i zh_CN -c -f UTF-8 -A /usr/share/locale/locale.alias zh_CN.UTF-8 && locale-gen zh_CN.UTF-8 &&\
|
|
||||||
apt-get install -y tzdata && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&\
|
|
||||||
apt-get install -y libxrender1 && apt-get install -y libxt6 && apt-get install -y libxext-dev && apt-get install -y libfreetype6-dev &&\
|
|
||||||
apt-get install -y wget && apt-get install -y ttf-mscorefonts-installer && apt-get install -y fontconfig &&\
|
|
||||||
apt-get install ttf-wqy-microhei &&\
|
|
||||||
apt-get install ttf-wqy-zenhei &&\
|
|
||||||
apt-get install xfonts-wqy &&\
|
|
||||||
cd /tmp &&\
|
|
||||||
wget https://kkfileview.keking.cn/server-jre-8u251-linux-x64.tar.gz &&\
|
|
||||||
tar -zxf /tmp/server-jre-8u251-linux-x64.tar.gz && mv /tmp/jdk1.8.0_251 /usr/local/ &&\
|
|
||||||
|
|
||||||
# 安装 OpenOffice
|
|
||||||
# wget https://kkfileview.keking.cn/Apache_OpenOffice_4.1.6_Linux_x86-64_install-deb_zh-CN.tar.gz -cO openoffice_deb.tar.gz &&\
|
|
||||||
# tar -zxf /tmp/openoffice_deb.tar.gz && cd /tmp/zh-CN/DEBS &&\
|
|
||||||
# dpkg -i *.deb && dpkg -i desktop-integration/openoffice4.1-debian-menus_4.1.6-9790_all.deb &&\
|
|
||||||
|
|
||||||
# 安装 libreoffice
|
|
||||||
apt-get install -y libxinerama1 libcairo2 libcups2 libx11-xcb1 &&\
|
|
||||||
wget https://kkfileview.keking.cn/LibreOffice_7.1.4_Linux_x86-64_deb.tar.gz -cO libreoffice_deb.tar.gz &&\
|
|
||||||
tar -zxf /tmp/libreoffice_deb.tar.gz && cd /tmp/LibreOffice_7.1.4.2_Linux_x86-64_deb/DEBS &&\
|
|
||||||
dpkg -i *.deb &&\
|
|
||||||
|
|
||||||
rm -rf /tmp/* && rm -rf /var/lib/apt/lists/* &&\
|
|
||||||
cd /usr/share/fonts/chinese &&\
|
|
||||||
mkfontscale &&\
|
|
||||||
mkfontdir &&\
|
|
||||||
fc-cache -fv
|
|
||||||
ENV JAVA_HOME /usr/local/jdk1.8.0_251
|
|
||||||
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
|
|
||||||
ENV PATH $PATH:$JAVA_HOME/bin
|
|
||||||
ENV LANG zh_CN.UTF-8
|
|
||||||
ENV LC_ALL zh_CN.UTF-8
|
|
||||||
ENV KKFILEVIEW_BIN_FOLDER /opt/kkFileView-4.0.0/bin
|
|
||||||
ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-Dspring.config.location=/opt/kkFileView-4.0.0/config/application.properties","-jar","/opt/kkFileView-4.0.0/bin/kkFileView-4.0.0.jar"]
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# file-online-preview
|
# kkFileView
|
||||||
|
|
||||||
[](https://github.com/kekingcn/kkFileView/blob/master/LICENSE)
|
[](https://github.com/kekingcn/kkFileView/blob/master/LICENSE)
|
||||||
|
|
||||||
|
|||||||
15
README.md
15
README.md
@@ -1,4 +1,4 @@
|
|||||||
# file-online-preview
|
# kkFileView
|
||||||
此项目为文件文档在线预览项目解决方案,对标业内付费产品有【[永中office](http://dcs.yozosoft.com/)】【[office365](http://www.officeweb365.com/)】【[idocv](https://www.idocv.com/)】等,在取得公司高层同意后以Apache协议开源出来反哺社区,在此特别感谢@唐老大的支持以及@端木详笑的贡献。该项目使用流行的spring boot搭建,易上手和部署,基本支持主流办公文档的在线预览,如doc,docx,Excel,pdf,txt,zip,rar,图片等等
|
此项目为文件文档在线预览项目解决方案,对标业内付费产品有【[永中office](http://dcs.yozosoft.com/)】【[office365](http://www.officeweb365.com/)】【[idocv](https://www.idocv.com/)】等,在取得公司高层同意后以Apache协议开源出来反哺社区,在此特别感谢@唐老大的支持以及@端木详笑的贡献。该项目使用流行的spring boot搭建,易上手和部署,基本支持主流办公文档的在线预览,如doc,docx,Excel,pdf,txt,zip,rar,图片等等
|
||||||
### 项目特性
|
### 项目特性
|
||||||
|
|
||||||
@@ -110,6 +110,19 @@ pdf预览模式预览效果如下
|
|||||||
|
|
||||||
### 历史更新记录
|
### 历史更新记录
|
||||||
|
|
||||||
|
> 2022年12月14日,v4.1.0 版本发布 :
|
||||||
|
|
||||||
|
1. 全新首页视觉 @wsd7747
|
||||||
|
2. tif图片预览兼容多页tif的pdf转换、jpg转换,以及jpg在线多页预览功能 @zhangzhen1979
|
||||||
|
3. 优化docker构建方案,使用分层构建方式 @yl-yue
|
||||||
|
4. 实现基于userToken缓存加密文件 @yl-yue
|
||||||
|
5. 实现加密word、ppt、excel文件预览 @yl-yue
|
||||||
|
6. Linux & Docker镜像升级LibreOffice 7.3
|
||||||
|
7. 更新OFD预览组件、更新tif预览组件、更新PPT水印支持
|
||||||
|
8. 大量其他升级优化 & 已知问题修复
|
||||||
|
|
||||||
|
感谢 @yl-yue @wsd7747 @zhangzhen1979 @tomhusky @shenghuadun @kischn.sun 的代码贡献
|
||||||
|
|
||||||
> 2021年7月6日,v4.0.0 版本发布 :
|
> 2021年7月6日,v4.0.0 版本发布 :
|
||||||
|
|
||||||
1. 底层集成OpenOffice替换为LibreOffice,Office文件兼容性增强,预览效果提升
|
1. 底层集成OpenOffice替换为LibreOffice,Office文件兼容性增强,预览效果提升
|
||||||
|
|||||||
38
docker/kkfileview-jdk/Dockerfile
Normal file
38
docker/kkfileview-jdk/Dockerfile
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
FROM ubuntu:20.04
|
||||||
|
MAINTAINER chenjh "842761733@qq.com"
|
||||||
|
# 内置一些常用的中文字体,避免普遍性乱码
|
||||||
|
COPY fonts/* /usr/share/fonts/chinese/
|
||||||
|
RUN apt-get clean && apt-get update &&\
|
||||||
|
sed -i 's/http:\/\/archive.ubuntu.com/https:\/\/mirrors.aliyun.com/g' /etc/apt/sources.list &&\
|
||||||
|
sed -i 's/# deb/deb/g' /etc/apt/sources.list &&\
|
||||||
|
apt-get install -y --reinstall ca-certificates &&\
|
||||||
|
apt-get clean && apt-get update &&\
|
||||||
|
apt-get install -y locales language-pack-zh-hans &&\
|
||||||
|
localedef -i zh_CN -c -f UTF-8 -A /usr/share/locale/locale.alias zh_CN.UTF-8 && locale-gen zh_CN.UTF-8 &&\
|
||||||
|
export DEBIAN_FRONTEND=noninteractive &&\
|
||||||
|
apt-get install -y tzdata && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&\
|
||||||
|
apt-get install -y fontconfig ttf-mscorefonts-installer ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy &&\
|
||||||
|
apt-get install -y wget &&\
|
||||||
|
cd /tmp &&\
|
||||||
|
wget https://kkfileview.keking.cn/server-jre-8u251-linux-x64.tar.gz &&\
|
||||||
|
tar -zxf /tmp/server-jre-8u251-linux-x64.tar.gz && mv /tmp/jdk1.8.0_251 /usr/local/ &&\
|
||||||
|
|
||||||
|
# 安装 libreoffice
|
||||||
|
apt-get install -y libxrender1 libxinerama1 libxt6 libxext-dev libfreetype6-dev libcairo2 libcups2 libx11-xcb1 libnss3 &&\
|
||||||
|
wget https://kkfileview.keking.cn/LibreOffice_7.3.7_Linux_x86-64_deb.tar.gz -cO libreoffice_deb.tar.gz &&\
|
||||||
|
tar -zxf /tmp/libreoffice_deb.tar.gz && cd /tmp/LibreOffice_7.3.7.2_Linux_x86-64_deb/DEBS &&\
|
||||||
|
dpkg -i *.deb &&\
|
||||||
|
|
||||||
|
# 清理临时文件
|
||||||
|
rm -rf /tmp/* && rm -rf /var/lib/apt/lists/* &&\
|
||||||
|
cd /usr/share/fonts/chinese &&\
|
||||||
|
mkfontscale &&\
|
||||||
|
mkfontdir &&\
|
||||||
|
fc-cache -fv
|
||||||
|
|
||||||
|
ENV JAVA_HOME /usr/local/jdk1.8.0_251
|
||||||
|
ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
|
||||||
|
ENV PATH $PATH:$JAVA_HOME/bin
|
||||||
|
ENV LANG zh_CN.UTF-8
|
||||||
|
ENV LC_ALL zh_CN.UTF-8
|
||||||
|
CMD ["/bin/bash"]
|
||||||
2
docker/kkfileview-jdk/docker build.txt
Normal file
2
docker/kkfileview-jdk/docker build.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# 执行如下命令构建基础镜像,加快kkfileview docker镜像构建与发布
|
||||||
|
docker build --tag keking/kkfileview-jdk:4.1.1 .
|
||||||
@@ -3,11 +3,10 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>filepreview</artifactId>
|
<artifactId>kkFileView-parent</artifactId>
|
||||||
<groupId>cn.keking</groupId>
|
<groupId>cn.keking</groupId>
|
||||||
<version>4.0.0</version>
|
<version>4.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>office-plugin</artifactId>
|
<artifactId>office-plugin</artifactId>
|
||||||
@@ -27,19 +26,9 @@
|
|||||||
<version>2.7</version>
|
<version>2.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openoffice</groupId>
|
<groupId>org.libreoffice</groupId>
|
||||||
<artifactId>juh</artifactId>
|
<artifactId>libreoffice</artifactId>
|
||||||
<version>3.2.1</version>
|
<version>7.1.4</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openoffice</groupId>
|
|
||||||
<artifactId>ridl</artifactId>
|
|
||||||
<version>3.2.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openoffice</groupId>
|
|
||||||
<artifactId>unoil</artifactId>
|
|
||||||
<version>3.2.1</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<!-- for the command line tool -->
|
<!-- for the command line tool -->
|
||||||
@@ -72,6 +61,7 @@
|
|||||||
<plugins>
|
<plugins>
|
||||||
<!-- 要将源码放上去,需要加入这个插件 -->
|
<!-- 要将源码放上去,需要加入这个插件 -->
|
||||||
<plugin>
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>2.1</version>
|
<version>2.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
@@ -86,16 +76,6 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>2.3.2</version>
|
|
||||||
<configuration>
|
|
||||||
<source>1.6</source>
|
|
||||||
<target>1.6</target>
|
|
||||||
<encoding>UTF-8</encoding>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
@@ -142,21 +122,8 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>cobertura-maven-plugin</artifactId>
|
<artifactId>cobertura-maven-plugin</artifactId>
|
||||||
<version>2.4</version>
|
<version>2.7</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</reporting>
|
</reporting>
|
||||||
<!-- distribute目录 -->
|
|
||||||
<distributionManagement>
|
|
||||||
<repository>
|
|
||||||
<id>repo</id>
|
|
||||||
<name>User Project Releases</name>
|
|
||||||
<url>http://192.168.1.204:8081/nexus/content/repositories/releases</url>
|
|
||||||
</repository>
|
|
||||||
<snapshotRepository>
|
|
||||||
<id>repo</id>
|
|
||||||
<name>User Project SNAPSHOTS</name>
|
|
||||||
<url>http://192.168.1.204:8081/nexus/content/repositories/snapshots</url>
|
|
||||||
</snapshotRepository>
|
|
||||||
</distributionManagement>
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -12,18 +12,6 @@
|
|||||||
//
|
//
|
||||||
package org.artofsolving.jodconverter;
|
package org.artofsolving.jodconverter;
|
||||||
|
|
||||||
import static org.artofsolving.jodconverter.office.OfficeUtils.SERVICE_DESKTOP;
|
|
||||||
import static org.artofsolving.jodconverter.office.OfficeUtils.cast;
|
|
||||||
import static org.artofsolving.jodconverter.office.OfficeUtils.toUnoProperties;
|
|
||||||
import static org.artofsolving.jodconverter.office.OfficeUtils.toUrl;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.artofsolving.jodconverter.office.OfficeContext;
|
|
||||||
import org.artofsolving.jodconverter.office.OfficeException;
|
|
||||||
import org.artofsolving.jodconverter.office.OfficeTask;
|
|
||||||
|
|
||||||
import com.sun.star.frame.XComponentLoader;
|
import com.sun.star.frame.XComponentLoader;
|
||||||
import com.sun.star.frame.XStorable;
|
import com.sun.star.frame.XStorable;
|
||||||
import com.sun.star.io.IOException;
|
import com.sun.star.io.IOException;
|
||||||
@@ -32,6 +20,14 @@ import com.sun.star.lang.XComponent;
|
|||||||
import com.sun.star.task.ErrorCodeIOException;
|
import com.sun.star.task.ErrorCodeIOException;
|
||||||
import com.sun.star.util.CloseVetoException;
|
import com.sun.star.util.CloseVetoException;
|
||||||
import com.sun.star.util.XCloseable;
|
import com.sun.star.util.XCloseable;
|
||||||
|
import org.artofsolving.jodconverter.office.OfficeContext;
|
||||||
|
import org.artofsolving.jodconverter.office.OfficeException;
|
||||||
|
import org.artofsolving.jodconverter.office.OfficeTask;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.artofsolving.jodconverter.office.OfficeUtils.*;
|
||||||
|
|
||||||
public abstract class AbstractConversionTask implements OfficeTask {
|
public abstract class AbstractConversionTask implements OfficeTask {
|
||||||
|
|
||||||
@@ -47,6 +43,7 @@ public abstract class AbstractConversionTask implements OfficeTask {
|
|||||||
|
|
||||||
protected abstract Map<String,?> getStoreProperties(File outputFile, XComponent document);
|
protected abstract Map<String,?> getStoreProperties(File outputFile, XComponent document);
|
||||||
|
|
||||||
|
@Override
|
||||||
public void execute(OfficeContext context) throws OfficeException {
|
public void execute(OfficeContext context) throws OfficeException {
|
||||||
XComponent document = null;
|
XComponent document = null;
|
||||||
try {
|
try {
|
||||||
@@ -79,6 +76,7 @@ public abstract class AbstractConversionTask implements OfficeTask {
|
|||||||
}
|
}
|
||||||
XComponentLoader loader = cast(XComponentLoader.class, context.getService(SERVICE_DESKTOP));
|
XComponentLoader loader = cast(XComponentLoader.class, context.getService(SERVICE_DESKTOP));
|
||||||
Map<String,?> loadProperties = getLoadProperties(inputFile);
|
Map<String,?> loadProperties = getLoadProperties(inputFile);
|
||||||
|
|
||||||
XComponent document = null;
|
XComponent document = null;
|
||||||
try {
|
try {
|
||||||
document = loader.loadComponentFromURL(toUrl(inputFile), "_blank", 0, toUnoProperties(loadProperties));
|
document = loader.loadComponentFromURL(toUrl(inputFile), "_blank", 0, toUnoProperties(loadProperties));
|
||||||
|
|||||||
@@ -12,18 +12,18 @@
|
|||||||
//
|
//
|
||||||
package org.artofsolving.jodconverter;
|
package org.artofsolving.jodconverter;
|
||||||
|
|
||||||
import java.io.File;
|
import com.sun.star.document.UpdateDocMode;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.artofsolving.jodconverter.document.DefaultDocumentFormatRegistry;
|
import org.artofsolving.jodconverter.document.DefaultDocumentFormatRegistry;
|
||||||
import org.artofsolving.jodconverter.document.DocumentFormat;
|
import org.artofsolving.jodconverter.document.DocumentFormat;
|
||||||
import org.artofsolving.jodconverter.document.DocumentFormatRegistry;
|
import org.artofsolving.jodconverter.document.DocumentFormatRegistry;
|
||||||
|
import org.artofsolving.jodconverter.model.FileProperties;
|
||||||
import org.artofsolving.jodconverter.office.OfficeException;
|
import org.artofsolving.jodconverter.office.OfficeException;
|
||||||
import org.artofsolving.jodconverter.office.OfficeManager;
|
import org.artofsolving.jodconverter.office.OfficeManager;
|
||||||
|
|
||||||
import com.sun.star.document.UpdateDocMode;
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class OfficeDocumentConverter {
|
public class OfficeDocumentConverter {
|
||||||
|
|
||||||
@@ -60,14 +60,22 @@ public class OfficeDocumentConverter {
|
|||||||
public void convert(File inputFile, File outputFile) throws OfficeException {
|
public void convert(File inputFile, File outputFile) throws OfficeException {
|
||||||
String outputExtension = FilenameUtils.getExtension(outputFile.getName());
|
String outputExtension = FilenameUtils.getExtension(outputFile.getName());
|
||||||
DocumentFormat outputFormat = formatRegistry.getFormatByExtension(outputExtension);
|
DocumentFormat outputFormat = formatRegistry.getFormatByExtension(outputExtension);
|
||||||
convert(inputFile, outputFile, outputFormat);
|
convert(inputFile, outputFile, outputFormat, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void convert(File inputFile, File outputFile, DocumentFormat outputFormat) throws OfficeException {
|
public void convert(File inputFile, File outputFile, FileProperties fileProperties) throws OfficeException {
|
||||||
|
String outputExtension = FilenameUtils.getExtension(outputFile.getName());
|
||||||
|
DocumentFormat outputFormat = formatRegistry.getFormatByExtension(outputExtension);
|
||||||
|
convert(inputFile, outputFile, outputFormat, fileProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void convert(File inputFile, File outputFile, DocumentFormat outputFormat, FileProperties fileProperties) throws OfficeException {
|
||||||
String inputExtension = FilenameUtils.getExtension(inputFile.getName());
|
String inputExtension = FilenameUtils.getExtension(inputFile.getName());
|
||||||
DocumentFormat inputFormat = formatRegistry.getFormatByExtension(inputExtension);
|
DocumentFormat inputFormat = formatRegistry.getFormatByExtension(inputExtension);
|
||||||
|
Map<String, Object> properties = fileProperties.toMap();
|
||||||
|
properties.putAll(defaultLoadProperties);
|
||||||
StandardConversionTask conversionTask = new StandardConversionTask(inputFile, outputFile, outputFormat);
|
StandardConversionTask conversionTask = new StandardConversionTask(inputFile, outputFile, outputFormat);
|
||||||
conversionTask.setDefaultLoadProperties(defaultLoadProperties);
|
conversionTask.setDefaultLoadProperties(properties);
|
||||||
conversionTask.setInputFormat(inputFormat);
|
conversionTask.setInputFormat(inputFormat);
|
||||||
officeManager.execute(conversionTask);
|
officeManager.execute(conversionTask);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ package org.artofsolving.jodconverter.cli;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.commons.cli.CommandLineParser;
|
import org.apache.commons.cli.CommandLineParser;
|
||||||
@@ -86,7 +87,7 @@ public class Convert {
|
|||||||
DocumentFormatRegistry registry;
|
DocumentFormatRegistry registry;
|
||||||
if (commandLine.hasOption(OPTION_REGISTRY.getOpt())) {
|
if (commandLine.hasOption(OPTION_REGISTRY.getOpt())) {
|
||||||
File registryFile = new File(commandLine.getOptionValue(OPTION_REGISTRY.getOpt()));
|
File registryFile = new File(commandLine.getOptionValue(OPTION_REGISTRY.getOpt()));
|
||||||
registry = new JsonDocumentFormatRegistry(FileUtils.readFileToString(registryFile));
|
registry = new JsonDocumentFormatRegistry(FileUtils.readFileToString(registryFile, Charset.defaultCharset()));
|
||||||
} else {
|
} else {
|
||||||
registry = new DefaultDocumentFormatRegistry();
|
registry = new DefaultDocumentFormatRegistry();
|
||||||
}
|
}
|
||||||
@@ -122,5 +123,5 @@ public class Convert {
|
|||||||
officeManager.stop();
|
officeManager.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ package org.artofsolving.jodconverter.document;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ import org.json.JSONObject;
|
|||||||
public class JsonDocumentFormatRegistry extends SimpleDocumentFormatRegistry {
|
public class JsonDocumentFormatRegistry extends SimpleDocumentFormatRegistry {
|
||||||
|
|
||||||
public JsonDocumentFormatRegistry(InputStream input) throws JSONException, IOException {
|
public JsonDocumentFormatRegistry(InputStream input) throws JSONException, IOException {
|
||||||
readJsonArray(IOUtils.toString(input));
|
readJsonArray(IOUtils.toString(input, Charset.defaultCharset()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonDocumentFormatRegistry(String source) throws JSONException {
|
public JsonDocumentFormatRegistry(String source) throws JSONException {
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package org.artofsolving.jodconverter.model;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by kl on 2018/1/17.
|
||||||
|
* Content :
|
||||||
|
*/
|
||||||
|
public class FileProperties {
|
||||||
|
|
||||||
|
private String filePassword;
|
||||||
|
|
||||||
|
public FileProperties() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> toMap() {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
if (filePassword != null) {
|
||||||
|
map.put("Password", filePassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFilePassword() {
|
||||||
|
return filePassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilePassword(String filePassword) {
|
||||||
|
this.filePassword = filePassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ import static org.artofsolving.jodconverter.process.ProcessManager.PID_NOT_FOUND
|
|||||||
import static org.artofsolving.jodconverter.process.ProcessManager.PID_UNKNOWN;
|
import static org.artofsolving.jodconverter.process.ProcessManager.PID_UNKNOWN;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -134,11 +135,11 @@ class OfficeProcess {
|
|||||||
logger.fine("no %OFFICE_HOME%/basis-link found; assuming it's OOo 2.x and we don't need to append URE and Basic paths");
|
logger.fine("no %OFFICE_HOME%/basis-link found; assuming it's OOo 2.x and we don't need to append URE and Basic paths");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String basisLinkText = FileUtils.readFileToString(basisLink).trim();
|
String basisLinkText = FileUtils.readFileToString(basisLink, Charset.defaultCharset()).trim();
|
||||||
File basisHome = new File(officeHome, basisLinkText);
|
File basisHome = new File(officeHome, basisLinkText);
|
||||||
File basisProgram = new File(basisHome, "program");
|
File basisProgram = new File(basisHome, "program");
|
||||||
File ureLink = new File(basisHome, "ure-link");
|
File ureLink = new File(basisHome, "ure-link");
|
||||||
String ureLinkText = FileUtils.readFileToString(ureLink).trim();
|
String ureLinkText = FileUtils.readFileToString(ureLink, Charset.defaultCharset()).trim();
|
||||||
File ureHome = new File(basisHome, ureLinkText);
|
File ureHome = new File(basisHome, ureLinkText);
|
||||||
File ureBin = new File(ureHome, "bin");
|
File ureBin = new File(ureHome, "bin");
|
||||||
Map<String,String> environment = processBuilder.environment();
|
Map<String,String> environment = processBuilder.environment();
|
||||||
@@ -163,9 +164,9 @@ class OfficeProcess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class ExitCodeRetryable extends Retryable {
|
private class ExitCodeRetryable extends Retryable {
|
||||||
|
|
||||||
private int exitCode;
|
private int exitCode;
|
||||||
|
|
||||||
protected void attempt() throws TemporaryException, Exception {
|
protected void attempt() throws TemporaryException, Exception {
|
||||||
try {
|
try {
|
||||||
exitCode = process.exitValue();
|
exitCode = process.exitValue();
|
||||||
@@ -173,7 +174,7 @@ class OfficeProcess {
|
|||||||
throw new TemporaryException(illegalThreadStateException);
|
throw new TemporaryException(illegalThreadStateException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExitCode() {
|
public int getExitCode() {
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,9 +104,16 @@ public class OfficeUtils {
|
|||||||
"/opt/openoffice.org3",
|
"/opt/openoffice.org3",
|
||||||
"/opt/openoffice",
|
"/opt/openoffice",
|
||||||
"/opt/libreoffice",
|
"/opt/libreoffice",
|
||||||
|
"/opt/libreoffice6.0",
|
||||||
"/opt/libreoffice6.1",
|
"/opt/libreoffice6.1",
|
||||||
|
"/opt/libreoffice6.2",
|
||||||
|
"/opt/libreoffice6.3",
|
||||||
|
"/opt/libreoffice6.4",
|
||||||
"/opt/libreoffice7.0",
|
"/opt/libreoffice7.0",
|
||||||
"/opt/libreoffice7.1",
|
"/opt/libreoffice7.1",
|
||||||
|
"/opt/libreoffice7.2",
|
||||||
|
"/opt/libreoffice7.3",
|
||||||
|
"/opt/libreoffice7.4",
|
||||||
"/opt/openoffice4",
|
"/opt/openoffice4",
|
||||||
"/usr/lib/openoffice",
|
"/usr/lib/openoffice",
|
||||||
"/usr/lib/libreoffice"
|
"/usr/lib/libreoffice"
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
package org.artofsolving.jodconverter.process;
|
package org.artofsolving.jodconverter.process;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -25,11 +26,10 @@ import org.apache.commons.io.IOUtils;
|
|||||||
* <p>
|
* <p>
|
||||||
* Should Work on Solaris too, except that the command line string
|
* Should Work on Solaris too, except that the command line string
|
||||||
* returned by <tt>ps</tt> there is limited to 80 characters and this affects
|
* returned by <tt>ps</tt> there is limited to 80 characters and this affects
|
||||||
* {@link #findPid(String)}.
|
|
||||||
*/
|
*/
|
||||||
public class LinuxProcessManager implements ProcessManager {
|
public class LinuxProcessManager implements ProcessManager {
|
||||||
|
|
||||||
private static final Pattern PS_OUTPUT_LINE = Pattern.compile("^\\s*(\\d+)\\s+(.*)$");
|
private static final Pattern PS_OUTPUT_LINE = Pattern.compile("^\\s*(\\d+)\\s+(.*)$");
|
||||||
|
|
||||||
private String[] runAsArgs;
|
private String[] runAsArgs;
|
||||||
|
|
||||||
@@ -74,9 +74,7 @@ public class LinuxProcessManager implements ProcessManager {
|
|||||||
command = args;
|
command = args;
|
||||||
}
|
}
|
||||||
Process process = new ProcessBuilder(command).start();
|
Process process = new ProcessBuilder(command).start();
|
||||||
@SuppressWarnings("unchecked")
|
return IOUtils.readLines(process.getInputStream(), Charset.defaultCharset());
|
||||||
List<String> lines = IOUtils.readLines(process.getInputStream());
|
|
||||||
return lines;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class ConfigUtils {
|
|||||||
userDir = userDir.substring(0, userDir.length() - 4);
|
userDir = userDir.substring(0, userDir.length() - 4);
|
||||||
} else {
|
} else {
|
||||||
String separator = File.separator;
|
String separator = File.separator;
|
||||||
if (userDir.contains(MAIN_DIRECTORY_NAME)) {
|
if (userDir.endsWith(MAIN_DIRECTORY_NAME)) {
|
||||||
userDir = userDir + separator + "src" + separator + "main";
|
userDir = userDir + separator + "src" + separator + "main";
|
||||||
} else {
|
} else {
|
||||||
userDir = userDir + separator + MAIN_DIRECTORY_NAME + separator + "src" + separator + "main";
|
userDir = userDir + separator + MAIN_DIRECTORY_NAME + separator + "src" + separator + "main";
|
||||||
@@ -29,23 +29,45 @@ public class ConfigUtils {
|
|||||||
return userDir;
|
return userDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取环境变量,如果找不到则返回默认值
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
|
private static String getEnvOrDefault(String key, String def) {
|
||||||
|
String value = System.getenv(key);
|
||||||
|
return value == null ? def : value;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getOfficePluginPath() {
|
// 返回参数列表中第一个真实存在的路径,或者 null
|
||||||
String userDir = System.getenv("KKFILEVIEW_BIN_FOLDER");
|
private static String firstExists(File... paths) {
|
||||||
if (userDir == null) {
|
for (File path : paths) {
|
||||||
userDir = System.getProperty("user.dir");
|
if (path.exists()) {
|
||||||
}
|
return path.getAbsolutePath();
|
||||||
if (userDir.endsWith("bin")) {
|
|
||||||
userDir = userDir.substring(0, userDir.length() - 4);
|
|
||||||
} else {
|
|
||||||
String separator = File.separator;
|
|
||||||
if (!userDir.contains(OFFICE_PLUGIN_NAME)) {
|
|
||||||
userDir = userDir + separator + OFFICE_PLUGIN_NAME;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return userDir;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getOfficePluginPath() {
|
||||||
|
String userDir = System.getProperty("user.dir");
|
||||||
|
String binFolder = getEnvOrDefault("KKFILEVIEW_BIN_FOLDER", userDir);
|
||||||
|
|
||||||
|
File pluginPath = new File(binFolder);
|
||||||
|
|
||||||
|
// 如果指定了 bin 或其父目录,则返回父目录
|
||||||
|
// 否则在当前目录和父目录中寻找 office-plugin
|
||||||
|
if (new File(pluginPath, "bin").exists()) {
|
||||||
|
return pluginPath.getAbsolutePath();
|
||||||
|
|
||||||
|
} else if (pluginPath.exists() && pluginPath.getName().equals("bin")) {
|
||||||
|
return pluginPath.getParentFile().getAbsolutePath();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return firstExists(
|
||||||
|
new File(pluginPath, OFFICE_PLUGIN_NAME),
|
||||||
|
new File(pluginPath.getParentFile(), OFFICE_PLUGIN_NAME)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String getCustomizedConfigPath() {
|
public static String getCustomizedConfigPath() {
|
||||||
String homePath = getHomePath();
|
String homePath = getHomePath();
|
||||||
String separator = java.io.File.separator;
|
String separator = java.io.File.separator;
|
||||||
|
|||||||
35
pom.xml
35
pom.xml
@@ -5,14 +5,43 @@
|
|||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<groupId>cn.keking</groupId>
|
<groupId>cn.keking</groupId>
|
||||||
<artifactId>filepreview</artifactId>
|
<artifactId>kkFileView-parent</artifactId>
|
||||||
<version>4.0.0</version>
|
<version>4.1.0</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
|
||||||
<spring.boot.version>2.4.2</spring.boot.version>
|
<spring.boot.version>2.4.2</spring.boot.version>
|
||||||
|
<poi.version>5.2.2</poi.version>
|
||||||
|
<xdocreport.version>1.0.6</xdocreport.version>
|
||||||
|
<xstream.version>1.4.19</xstream.version>
|
||||||
|
<junrar.version>7.4.1</junrar.version>
|
||||||
|
<redisson.version>3.2.0</redisson.version>
|
||||||
|
<sevenzipjbinding.version>16.02-2.01</sevenzipjbinding.version>
|
||||||
|
<tukaani.version>1.8</tukaani.version>
|
||||||
|
<jchardet.version>1.0</jchardet.version>
|
||||||
|
<antlr.version>2.7.7</antlr.version>
|
||||||
|
<concurrentlinkedhashmap.version>1.4.2</concurrentlinkedhashmap.version>
|
||||||
|
<rocksdb.version>5.17.2</rocksdb.version>
|
||||||
|
<pdfbox.version>2.0.26</pdfbox.version>
|
||||||
|
<jai-imageio.version>1.4.0</jai-imageio.version>
|
||||||
|
<jbig2-imageio.version>3.0.4</jbig2-imageio.version>
|
||||||
|
<galimatias.version>0.2.1</galimatias.version>
|
||||||
|
<bytedeco.version>1.5.2</bytedeco.version>
|
||||||
|
<opencv.version>4.1.2-1.5.2</opencv.version>
|
||||||
|
<openblas.version>0.3.6-1.5.1</openblas.version>
|
||||||
|
<ffmpeg.version>4.2.1-1.5.2</ffmpeg.version>
|
||||||
|
<itext.version>2.1.7</itext.version>
|
||||||
|
<httpclient.version>3.1</httpclient.version>
|
||||||
|
|
||||||
|
<commons-cli.version>1.2</commons-cli.version>
|
||||||
|
<commons-net.version>3.6</commons-net.version>
|
||||||
|
<commons-lang3.version>3.7</commons-lang3.version>
|
||||||
|
<commons-compress.version>1.21</commons-compress.version>
|
||||||
|
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
@@ -22,7 +51,7 @@
|
|||||||
<module>server</module>
|
<module>server</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<name>file-online-preview</name>
|
<name>kkFileView-parent</name>
|
||||||
<description>专注文件在线预览服务</description>
|
<description>专注文件在线预览服务</description>
|
||||||
<url>https://github.com/kekingcn/kkFileView</url>
|
<url>https://github.com/kekingcn/kkFileView</url>
|
||||||
|
|
||||||
|
|||||||
BIN
server/lib/jai_codec-1.1.3.jar
Normal file
BIN
server/lib/jai_codec-1.1.3.jar
Normal file
Binary file not shown.
BIN
server/lib/jai_core-1.1.3.jar
Normal file
BIN
server/lib/jai_core-1.1.3.jar
Normal file
Binary file not shown.
355
server/pom.xml
355
server/pom.xml
@@ -4,9 +4,9 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>filepreview</artifactId>
|
<artifactId>kkFileView-parent</artifactId>
|
||||||
<groupId>cn.keking</groupId>
|
<groupId>cn.keking</groupId>
|
||||||
<version>4.0.0</version>
|
<version>4.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>kkFileView</artifactId>
|
<artifactId>kkFileView</artifactId>
|
||||||
@@ -25,9 +25,12 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>cn.keking</groupId>
|
||||||
<artifactId>spring-boot-starter-freemarker</artifactId>
|
<artifactId>office-plugin</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- web start -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
@@ -42,42 +45,32 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-jetty</artifactId>
|
<artifactId>spring-boot-starter-jetty</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-freemarker</artifactId>
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.keking</groupId>
|
|
||||||
<artifactId>office-plugin</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
<version>3.7</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- REDISSON -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.redisson</groupId>
|
|
||||||
<artifactId>redisson</artifactId>
|
|
||||||
<version>3.2.0</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- web end -->
|
||||||
|
|
||||||
|
<!-- poi start -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi</artifactId>
|
<artifactId>poi</artifactId>
|
||||||
<version>3.17</version>
|
<version>${poi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-scratchpad</artifactId>
|
<artifactId>poi-scratchpad</artifactId>
|
||||||
<version>3.12</version>
|
<version>${poi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>${poi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.opensagres.xdocreport</groupId>
|
<groupId>fr.opensagres.xdocreport</groupId>
|
||||||
<artifactId>org.apache.poi.xwpf.converter.core</artifactId>
|
<artifactId>org.apache.poi.xwpf.converter.core</artifactId>
|
||||||
<version>1.0.5</version>
|
<version>${xdocreport.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<artifactId>poi</artifactId>
|
<artifactId>poi</artifactId>
|
||||||
@@ -88,45 +81,220 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.opensagres.xdocreport</groupId>
|
<groupId>fr.opensagres.xdocreport</groupId>
|
||||||
<artifactId>org.apache.poi.xwpf.converter.xhtml</artifactId>
|
<artifactId>org.apache.poi.xwpf.converter.xhtml</artifactId>
|
||||||
<version>1.0.5</version>
|
<version>${xdocreport.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.opensagres.xdocreport</groupId>
|
<groupId>fr.opensagres.xdocreport</groupId>
|
||||||
<artifactId>fr.opensagres.xdocreport.document</artifactId>
|
<artifactId>fr.opensagres.xdocreport.document</artifactId>
|
||||||
<version>1.0.5</version>
|
<version>${xdocreport.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- poi start -->
|
||||||
|
|
||||||
|
<!-- 对 rar5 的支持 和其他众多压缩支持 可参考 package net.sf.sevenzipjbinding.ArchiveFormat; -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.sf.sevenzipjbinding</groupId>
|
||||||
|
<artifactId>sevenzipjbinding</artifactId>
|
||||||
|
<version>${sevenzipjbinding.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.sf.sevenzipjbinding</groupId>
|
||||||
|
<artifactId>sevenzipjbinding-all-platforms</artifactId>
|
||||||
|
<version>${sevenzipjbinding.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>${commons-lang3.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson</artifactId>
|
||||||
|
<version>${redisson.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 解压(apache) -->
|
<!-- 解压(apache) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-compress</artifactId>
|
<artifactId>commons-compress</artifactId>
|
||||||
<version>1.21</version>
|
<version>${commons-compress.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 解压(rar)-->
|
<!-- 解压(rar)-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.junrar</groupId>
|
<groupId>com.github.junrar</groupId>
|
||||||
<artifactId>junrar</artifactId>
|
<artifactId>junrar</artifactId>
|
||||||
<version>4.0.0</version>
|
<version>${junrar.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 解压(7z)-->
|
<!-- 解压(7z)-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.tukaani</groupId>
|
<groupId>org.tukaani</groupId>
|
||||||
<artifactId>xz</artifactId>
|
<artifactId>xz</artifactId>
|
||||||
<version>1.8</version>
|
<version>${tukaani.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.sourceforge.jchardet</groupId>
|
<groupId>net.sourceforge.jchardet</groupId>
|
||||||
<artifactId>jchardet</artifactId>
|
<artifactId>jchardet</artifactId>
|
||||||
<version>1.0</version>
|
<version>${jchardet.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>antlr</groupId>
|
<groupId>antlr</groupId>
|
||||||
<artifactId>antlr</artifactId>
|
<artifactId>antlr</artifactId>
|
||||||
<version>2.7.7</version>
|
<version>${antlr.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-cli</groupId>
|
||||||
|
<artifactId>commons-cli</artifactId>
|
||||||
|
<version>${commons-cli.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- FTP -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-net</groupId>
|
||||||
|
<artifactId>commons-net</artifactId>
|
||||||
|
<version>${commons-net.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.thoughtworks.xstream</groupId>
|
||||||
|
<artifactId>xstream</artifactId>
|
||||||
|
<version>${xstream.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.googlecode.concurrentlinkedhashmap</groupId>
|
||||||
|
<artifactId>concurrentlinkedhashmap-lru</artifactId>
|
||||||
|
<version>${concurrentlinkedhashmap.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.rocksdb</groupId>
|
||||||
|
<artifactId>rocksdbjni</artifactId>
|
||||||
|
<version>${rocksdb.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
|
<artifactId>pdfbox</artifactId>
|
||||||
|
<version>${pdfbox.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
|
<artifactId>pdfbox-tools</artifactId>
|
||||||
|
<version>${pdfbox.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.jai-imageio</groupId>
|
||||||
|
<artifactId>jai-imageio-jpeg2000</artifactId>
|
||||||
|
<version>${jai-imageio.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.jai-imageio</groupId>
|
||||||
|
<artifactId>jai-imageio-core</artifactId>
|
||||||
|
<version>${jai-imageio.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
|
<artifactId>jbig2-imageio</artifactId>
|
||||||
|
<version>${jbig2-imageio.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aspose</groupId>
|
||||||
|
<artifactId>aspose-cad</artifactId>
|
||||||
|
<version>19.9</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${pom.basedir}/lib/aspose-cad-19.9.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
<!-- 编码识别 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cpdetector</groupId>
|
||||||
|
<artifactId>cpdetector</artifactId>
|
||||||
|
<version>1.04</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${pom.basedir}/lib/cpdetector-1.04.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
<!-- url 规范化 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.mola.galimatias</groupId>
|
||||||
|
<artifactId>galimatias</artifactId>
|
||||||
|
<version>${galimatias.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 以下是bytedeco 基于opencv ffmpeg封装的javacv,用于视频处理 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bytedeco</groupId>
|
||||||
|
<artifactId>javacv</artifactId>
|
||||||
|
<version>${bytedeco.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bytedeco</groupId>
|
||||||
|
<artifactId>javacpp</artifactId>
|
||||||
|
<version>${bytedeco.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 此版本中主要兼容linux和windows系统,如需兼容其他系统平台,请引入对应依赖即可 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bytedeco</groupId>
|
||||||
|
<artifactId>opencv</artifactId>
|
||||||
|
<version>${opencv.version}</version>
|
||||||
|
<classifier>linux-x86_64</classifier>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bytedeco</groupId>
|
||||||
|
<artifactId>opencv</artifactId>
|
||||||
|
<version>${opencv.version}</version>
|
||||||
|
<classifier>windows-x86_64</classifier>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bytedeco</groupId>
|
||||||
|
<artifactId>openblas</artifactId>
|
||||||
|
<version>${openblas.version}</version>
|
||||||
|
<classifier>linux-x86_64</classifier>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bytedeco</groupId>
|
||||||
|
<artifactId>openblas</artifactId>
|
||||||
|
<version>${openblas.version}</version>
|
||||||
|
<classifier>windows-x86_64</classifier>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bytedeco</groupId>
|
||||||
|
<artifactId>ffmpeg</artifactId>
|
||||||
|
<version>${ffmpeg.version}</version>
|
||||||
|
<classifier>linux-x86_64</classifier>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bytedeco</groupId>
|
||||||
|
<artifactId>ffmpeg</artifactId>
|
||||||
|
<version>${ffmpeg.version}</version>
|
||||||
|
<classifier>windows-x86_64</classifier>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lowagie</groupId>
|
||||||
|
<artifactId>itext</artifactId>
|
||||||
|
<version>${itext.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.media</groupId>
|
||||||
|
<artifactId>jai_core</artifactId>
|
||||||
|
<version>1.1.3</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${pom.basedir}/lib/jai_core-1.1.3.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.media</groupId>
|
||||||
|
<artifactId>jai_codec</artifactId>
|
||||||
|
<version>1.1.3</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${pom.basedir}/lib/jai_codec-1.1.3.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- test dependency - start -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-httpclient</groupId>
|
<groupId>commons-httpclient</groupId>
|
||||||
<artifactId>commons-httpclient</artifactId>
|
<artifactId>commons-httpclient</artifactId>
|
||||||
<version>3.1</version>
|
<version>${httpclient.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
@@ -135,121 +303,7 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<!-- test dependency - end -->
|
||||||
<groupId>commons-cli</groupId>
|
|
||||||
<artifactId>commons-cli</artifactId>
|
|
||||||
<version>1.2</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- FTP -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-net</groupId>
|
|
||||||
<artifactId>commons-net</artifactId>
|
|
||||||
<version>3.6</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.thoughtworks.xstream</groupId>
|
|
||||||
<artifactId>xstream</artifactId>
|
|
||||||
<version>1.4.17</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.googlecode.concurrentlinkedhashmap</groupId>
|
|
||||||
<artifactId>concurrentlinkedhashmap-lru</artifactId>
|
|
||||||
<version>1.4.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.rocksdb</groupId>
|
|
||||||
<artifactId>rocksdbjni</artifactId>
|
|
||||||
<version>5.17.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.pdfbox</groupId>
|
|
||||||
<artifactId>pdfbox</artifactId>
|
|
||||||
<version>2.0.24</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.pdfbox</groupId>
|
|
||||||
<artifactId>pdfbox-tools</artifactId>
|
|
||||||
<version>2.0.15</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.aspose</groupId>
|
|
||||||
<artifactId>aspose-cad</artifactId>
|
|
||||||
<version>19.9</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${basedir}/lib/aspose-cad-19.9.jar</systemPath>
|
|
||||||
</dependency>
|
|
||||||
<!-- 编码识别 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>cpdetector</groupId>
|
|
||||||
<artifactId>cpdetector</artifactId>
|
|
||||||
<version>1.04</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${basedir}/lib/cpdetector-1.04.jar</systemPath>
|
|
||||||
</dependency>
|
|
||||||
<!-- url 规范化 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.mola.galimatias</groupId>
|
|
||||||
<artifactId>galimatias</artifactId>
|
|
||||||
<version>0.2.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 以下是bytedeco 基于opencv ffmpeg封装的javacv,用于视频处理 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bytedeco</groupId>
|
|
||||||
<artifactId>javacv</artifactId>
|
|
||||||
<version>1.5.2</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bytedeco</groupId>
|
|
||||||
<artifactId>javacpp</artifactId>
|
|
||||||
<version>1.5.2</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 此版本中主要兼容linux和windows系统,如需兼容其他系统平台,请引入对应依赖即可 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bytedeco</groupId>
|
|
||||||
<artifactId>opencv</artifactId>
|
|
||||||
<version>4.1.2-1.5.2</version>
|
|
||||||
<classifier>linux-x86_64</classifier>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bytedeco</groupId>
|
|
||||||
<artifactId>opencv</artifactId>
|
|
||||||
<version>4.1.2-1.5.2</version>
|
|
||||||
<classifier>windows-x86_64</classifier>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bytedeco</groupId>
|
|
||||||
<artifactId>openblas</artifactId>
|
|
||||||
<version>0.3.6-1.5.1</version>
|
|
||||||
<classifier>linux-x86_64</classifier>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bytedeco</groupId>
|
|
||||||
<artifactId>openblas</artifactId>
|
|
||||||
<version>0.3.6-1.5.1</version>
|
|
||||||
<classifier>windows-x86_64</classifier>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bytedeco</groupId>
|
|
||||||
<artifactId>ffmpeg</artifactId>
|
|
||||||
<version>4.2.1-1.5.2</version>
|
|
||||||
<classifier>linux-x86_64</classifier>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bytedeco</groupId>
|
|
||||||
<artifactId>ffmpeg</artifactId>
|
|
||||||
<version>4.2.1-1.5.2</version>
|
|
||||||
<classifier>windows-x86_64</classifier>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -283,7 +337,9 @@
|
|||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<version>3.4.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<appendAssemblyId>false</appendAssemblyId>
|
<appendAssemblyId>false</appendAssemblyId>
|
||||||
<descriptors>
|
<descriptors>
|
||||||
@@ -303,5 +359,4 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
cd /tmp
|
cd /tmp
|
||||||
|
|
||||||
install_redhat() {
|
install_redhat() {
|
||||||
wget https://kkfileview.keking.cn/LibreOffice_7.1.4_Linux_x86-64_rpm.tar.gz -cO LibreOffice_7_rpm.tar.gz && tar -zxf /tmp/LibreOffice_7_rpm.tar.gz && cd /tmp/LibreOffice_7.1.4.2_Linux_x86-64_rpm/RPMS
|
wget https://kkfileview.keking.cn/LibreOffice_7.3.7_Linux_x86-64_rpm.tar.gz -cO LibreOffice_7_rpm.tar.gz && tar -zxf /tmp/LibreOffice_7_rpm.tar.gz && cd /tmp/LibreOffice_7.3.7.2_Linux_x86-64_rpm/RPMS
|
||||||
echo $?
|
echo $?
|
||||||
if [ $? -eq 0 ];then
|
if [ $? -eq 0 ];then
|
||||||
yum install -y libXext.x86_64
|
yum install -y libSM.x86_64 libXrender.x86_64 libXext.x86_64
|
||||||
yum groupinstall -y "X Window System"
|
yum groupinstall -y "X Window System"
|
||||||
yum installlocalho
|
yum localinstall -y *.rpm
|
||||||
echo 'install finshed...'
|
echo 'install finshed...'
|
||||||
else
|
else
|
||||||
echo 'download package error...'
|
echo 'download package error...'
|
||||||
@@ -15,7 +15,7 @@ install_redhat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
install_ubuntu() {
|
install_ubuntu() {
|
||||||
wget https://kkfileview.keking.cn/LibreOffice_7.1.4_Linux_x86-64_deb.tar.gz -cO LibreOffice_7_deb.gz && tar -zxf /tmp/LibreOffice_7_deb.tar.gz && cd /tmp/LibreOffice_7.1.4.2_Linux_x86-deb/RPMS
|
wget https://kkfileview.keking.cn/LibreOffice_7.3.7_Linux_x86-64_deb.tar.gz -cO LibreOffice_7_deb.tar.gz && tar -zxf /tmp/LibreOffice_7_deb.tar.gz && cd /tmp/LibreOffice_7.3.7.2_Linux_x86-64_deb/DEBS
|
||||||
echo $?
|
echo $?
|
||||||
if [ $? -eq 0 ];then
|
if [ $? -eq 0 ];then
|
||||||
apt-get install -y libxinerama1 libcairo2 libcups2 libx11-xcb1
|
apt-get install -y libxinerama1 libcairo2 libcups2 libx11-xcb1
|
||||||
@@ -33,4 +33,4 @@ if [ -f "/etc/redhat-release" ]; then
|
|||||||
else
|
else
|
||||||
apt-get install -y wget
|
apt-get install -y wget
|
||||||
install_ubuntu
|
install_ubuntu
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,2 +1,36 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
kill -15 `ps -ef|grep kkFileView|awk 'NR==1{print $2}'`
|
#
|
||||||
|
#
|
||||||
|
#############################
|
||||||
|
# Author: sanxi
|
||||||
|
# Version: 1.0
|
||||||
|
# Date: 2021/09/17
|
||||||
|
# Description: v1.0:修改kkFileView关闭进程机制
|
||||||
|
#############################
|
||||||
|
#
|
||||||
|
KKFILEVIEW_BIN_FOLDER=$(cd "$(dirname "$0")" || exit 1 ;pwd)
|
||||||
|
PID_FILE_NAME="kkFileView.pid"
|
||||||
|
PID_FILE="${KKFILEVIEW_BIN_FOLDER}/${PID_FILE_NAME}"
|
||||||
|
export KKFILEVIEW_BIN_FOLDER=$KKFILEVIEW_BIN_FOLDER
|
||||||
|
#
|
||||||
|
## pid文件是否存在
|
||||||
|
if [ ! -e "$PID_FILE" ]; then
|
||||||
|
echo "kkFileView.pid文件不存在!"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
## 文件不为空代表程序正在运行,则循环关闭进程。
|
||||||
|
if [ -s "$PID_FILE" ]; then
|
||||||
|
# 读取pid文件内容,开启while循环读取每一行文本赋予给变量PID_FILE。
|
||||||
|
cat "${PID_FILE}" | while read PID;do
|
||||||
|
## 如已读取完毕,则退出脚本。
|
||||||
|
[ -z "$PID" ] && exit 2
|
||||||
|
echo "正在停止进程:${PID}..."
|
||||||
|
## 正常停止进程
|
||||||
|
kill -15 "${PID}" && echo "进程:${PID}停止成功!"
|
||||||
|
done
|
||||||
|
# 关闭所有进程后,重置pid。
|
||||||
|
cat /dev/null > "$PID_FILE"
|
||||||
|
else
|
||||||
|
echo "kkFileView进程尚未运行!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ cd "%KKFILEVIEW_BIN_FOLDER%"
|
|||||||
echo Using KKFILEVIEW_BIN_FOLDER %KKFILEVIEW_BIN_FOLDER%
|
echo Using KKFILEVIEW_BIN_FOLDER %KKFILEVIEW_BIN_FOLDER%
|
||||||
echo Starting kkFileView...
|
echo Starting kkFileView...
|
||||||
echo Please check log file in ../log/kkFileView.log for more information
|
echo Please check log file in ../log/kkFileView.log for more information
|
||||||
echo You can get help in our official homesite: https://kkFileView.keking.cn
|
echo You can get help in our official home site: https://kkFileView.keking.cn
|
||||||
|
echo If you need further help, please join our kk opensource community: https://t.zsxq.com/09ZHSXbsQ
|
||||||
echo If this project is helpful to you, please star it on https://gitee.com/kekingcn/file-online-preview/stargazers
|
echo If this project is helpful to you, please star it on https://gitee.com/kekingcn/file-online-preview/stargazers
|
||||||
java -Dspring.config.location=..\config\application.properties -jar kkFileView-4.0.0.jar -> ..\log\kkFileView.log
|
java -Dspring.config.location=..\config\application.properties -jar kkFileView-4.1.0.jar -> ..\log\kkFileView.log
|
||||||
|
|||||||
@@ -1,32 +1,62 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
DIR_HOME=("/opt/openoffice.org3" "/opt/libreoffice" "/opt/libreoffice6.1" "/opt/libreoffice7.0" "/opt/libreoffice7.1" "/opt/openoffice4" "/usr/lib/openoffice" "/usr/lib/libreoffice" "/usr/lib64/libreoffice")
|
#
|
||||||
|
#
|
||||||
|
#############################
|
||||||
|
# First_Author: 凯京科技
|
||||||
|
# Second_Author: sanxi
|
||||||
|
# Version: 1.1
|
||||||
|
# Date: 2021/09/17
|
||||||
|
# Description: v1.1:修改进程启动机制为pid形式。
|
||||||
|
#############################
|
||||||
|
#
|
||||||
|
DIR_HOME=("/opt/openoffice.org3" "/opt/libreoffice" "/opt/libreoffice6.1" "/opt/libreoffice7.0" "/opt/libreoffice7.1" "/opt/libreoffice7.2" "/opt/libreoffice7.3" "/opt/libreoffice7.4" "/opt/openoffice4" "/usr/lib/openoffice" "/usr/lib/libreoffice")
|
||||||
FLAG=
|
FLAG=
|
||||||
OFFICE_HOME=
|
OFFICE_HOME=
|
||||||
KKFILEVIEW_BIN_FOLDER=$(cd "$(dirname "$0")";pwd)
|
KKFILEVIEW_BIN_FOLDER=$(cd "$(dirname "$0")" || exit 1 ;pwd)
|
||||||
|
PID_FILE_NAME="kkFileView.pid"
|
||||||
|
PID_FILE="${KKFILEVIEW_BIN_FOLDER}/${PID_FILE_NAME}"
|
||||||
export KKFILEVIEW_BIN_FOLDER=$KKFILEVIEW_BIN_FOLDER
|
export KKFILEVIEW_BIN_FOLDER=$KKFILEVIEW_BIN_FOLDER
|
||||||
cd $KKFILEVIEW_BIN_FOLDER
|
#
|
||||||
echo "Using KKFILEVIEW_BIN_FOLDER $KKFILEVIEW_BIN_FOLDER"
|
## 如pid文件不存在则自动创建
|
||||||
grep 'office\.home' ../config/application.properties | grep '!^#'
|
if [ ! -f ${PID_FILE_NAME} ]; then
|
||||||
if [ $? -eq 0 ]; then
|
touch "${KKFILEVIEW_BIN_FOLDER}/${PID_FILE_NAME}"
|
||||||
echo "Using customized office.home"
|
fi
|
||||||
else
|
## 判断当前是否有进程处于运行状态
|
||||||
for i in ${DIR_HOME[@]}
|
if [ -s "${PID_FILE}" ]; then
|
||||||
do
|
PID=$(cat "${PID_FILE}")
|
||||||
if [ -f $i"/program/soffice.bin" ]; then
|
echo "进程已处于运行状态,进程号为:${PID}"
|
||||||
FLAG=true
|
exit 1
|
||||||
OFFICE_HOME=${i}
|
else
|
||||||
break
|
cd "$KKFILEVIEW_BIN_FOLDER" || exit 1
|
||||||
fi
|
echo "Using KKFILEVIEW_BIN_FOLDER $KKFILEVIEW_BIN_FOLDER"
|
||||||
done
|
grep 'office\.home' ../config/application.properties | grep '!^#'
|
||||||
if [ ! -n "${FLAG}" ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Installing OpenOffice"
|
echo "Using customized office.home"
|
||||||
sh ./install.sh
|
else
|
||||||
else
|
for i in ${DIR_HOME[@]}
|
||||||
echo "Detected office component has been installed in $OFFICE_HOME"
|
do
|
||||||
fi
|
if [ -f "$i/program/soffice.bin" ]; then
|
||||||
|
FLAG=true
|
||||||
|
OFFICE_HOME=${i}
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ ! -n "${FLAG}" ]; then
|
||||||
|
echo "Installing LibreOffice"
|
||||||
|
sh ./install.sh
|
||||||
|
else
|
||||||
|
echo "Detected office component has been installed in $OFFICE_HOME"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
## 启动kkFileView
|
||||||
|
echo "Starting kkFileView..."
|
||||||
|
nohup java -Dfile.encoding=UTF-8 -Dspring.config.location=../config/application.properties -jar kkFileView-4.1.0.jar > ../log/kkFileView.log 2>&1 &
|
||||||
|
echo "Please execute ./showlog.sh to check log for more information"
|
||||||
|
echo "You can get help in our official home site: https://kkFileView.keking.cn"
|
||||||
|
echo "If you need further help, please join our kk opensource community: https://t.zsxq.com/09ZHSXbsQ"
|
||||||
|
echo "If this project is helpful to you, please star it on https://gitee.com/kekingcn/file-online-preview/stargazers"
|
||||||
|
PROCESS=$(ps -ef | grep kkFileView | awk 'NR==1{print $2}')
|
||||||
|
# 启动成功后将进程号写入pid文件
|
||||||
|
echo "$PROCESS" > "$PID_FILE"
|
||||||
fi
|
fi
|
||||||
echo "Starting kkFileView..."
|
|
||||||
echo "Please execute ./showlog.sh to check log for more information"
|
|
||||||
echo "You can get help in our official homesite: https://kkFileView.keking.cn"
|
|
||||||
echo "If this project is helpful to you, please star it on https://gitee.com/kekingcn/file-online-preview/stargazers"
|
|
||||||
nohup java -Dfile.encoding=UTF-8 -Dspring.config.location=../config/application.properties -jar kkFileView-4.0.0.jar > ../log/kkFileView.log 2>&1 &
|
|
||||||
|
|||||||
@@ -22,9 +22,15 @@ office.plugin.server.ports = 2001,2002
|
|||||||
## office 转换服务 task 超时时间,默认五分钟
|
## office 转换服务 task 超时时间,默认五分钟
|
||||||
office.plugin.task.timeout = 5m
|
office.plugin.task.timeout = 5m
|
||||||
|
|
||||||
#文件资源路径(默认为打包根路径下的file目录下)
|
#预览生成资源路径(默认为打包根路径下的file目录下)
|
||||||
#file.dir = D:\\kkFileview\\
|
#file.dir = D:\\kkFileview\\
|
||||||
file.dir = ${KK_FILE_DIR:default}
|
file.dir = ${KK_FILE_DIR:default}
|
||||||
|
|
||||||
|
#允许预览的本地文件夹 默认不允许任何本地文件被预览
|
||||||
|
#file.dir = D:\\kkFileview\\
|
||||||
|
local.preview.dir = ${KK_LOCAL_PREVIEW_DIR:default}
|
||||||
|
|
||||||
|
|
||||||
#openoffice home路径
|
#openoffice home路径
|
||||||
#office.home = C:\\Program Files (x86)\\OpenOffice 4
|
#office.home = C:\\Program Files (x86)\\OpenOffice 4
|
||||||
office.home = ${KK_OFFICE_HOME:default}
|
office.home = ${KK_OFFICE_HOME:default}
|
||||||
@@ -65,8 +71,16 @@ office.preview.type = ${KK_OFFICE_PREVIEW_TYPE:image}
|
|||||||
#是否关闭office预览切换开关,默认为false,可配置为true关闭
|
#是否关闭office预览切换开关,默认为false,可配置为true关闭
|
||||||
office.preview.switch.disabled = ${KK_OFFICE_PREVIEW_SWITCH_DISABLED:false}
|
office.preview.switch.disabled = ${KK_OFFICE_PREVIEW_SWITCH_DISABLED:false}
|
||||||
|
|
||||||
|
#是否禁止演示模式
|
||||||
|
pdf.presentationMode.disable = ${KK_PDF_PRESENTATION_MODE_DISABLE:true}
|
||||||
|
#是否禁止打开文件
|
||||||
|
pdf.openFile.disable = ${KK_PDF_OPEN_FILE_DISABLE:true}
|
||||||
|
#是否禁止打印转换生成的pdf文件
|
||||||
|
pdf.print.disable = ${KK_PDF_PRINT_DISABLE:true}
|
||||||
#是否禁止下载转换生成的pdf文件
|
#是否禁止下载转换生成的pdf文件
|
||||||
pdf.download.disable = ${KK_PDF_DOWNLOAD_DISABLE:true}
|
pdf.download.disable = ${KK_PDF_DOWNLOAD_DISABLE:true}
|
||||||
|
#是否禁止bookmark
|
||||||
|
pdf.bookmark.disable = ${KK_PDF_BOOKMARK_DISABLE:true}
|
||||||
#是否禁用首页文件上传
|
#是否禁用首页文件上传
|
||||||
file.upload.disable = ${KK_FILE_UPLOAD_ENABLED:false}
|
file.upload.disable = ${KK_FILE_UPLOAD_ENABLED:false}
|
||||||
|
|
||||||
@@ -100,3 +114,6 @@ watermark.height = ${WATERMARK_HEIGHT:80}
|
|||||||
#水印倾斜度数,要求设置在大于等于0,小于90
|
#水印倾斜度数,要求设置在大于等于0,小于90
|
||||||
watermark.angle = ${WATERMARK_ANGLE:10}
|
watermark.angle = ${WATERMARK_ANGLE:10}
|
||||||
|
|
||||||
|
#Tif类型图片浏览模式:tif(利用前端js插件浏览);jpg(转换为jpg后前端显示);pdf(转换为pdf后显示,便于打印)
|
||||||
|
tif.preview.type = ${KK_TIF_PREVIEW_TYPE:tif}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
[#-- @ftlvariable name="file" type="cn.keking.model.FileAttribute" --]
|
[#-- @ftlvariable name="file" type="cn.keking.model.FileAttribute" --]
|
||||||
[#-- @ftlvariable name="fileName" type="java.lang.String" --]
|
[#-- @ftlvariable name="fileName" type="java.lang.String" --]
|
||||||
[#-- @ftlvariable name="fileTree" type="java.lang.String" --]
|
[#-- @ftlvariable name="fileTree" type="java.lang.String" --]
|
||||||
|
[#-- @ftlvariable name="needFilePassword" type="java.lang.Boolean" --]
|
||||||
|
[#-- @ftlvariable name="filePasswordError" type="java.lang.Boolean" --]
|
||||||
[#-- @ftlvariable name="baseUrl" type="java.lang.String" --]
|
[#-- @ftlvariable name="baseUrl" type="java.lang.String" --]
|
||||||
[#-- @ftlvariable name="imgUrls" type="String" --]
|
[#-- @ftlvariable name="imgUrls" type="String" --]
|
||||||
[#-- @ftlvariable name="textData" type="java.lang.String" --]
|
[#-- @ftlvariable name="textData" type="java.lang.String" --]
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package cn.keking;
|
package cn.keking;
|
||||||
|
|
||||||
import cn.keking.config.AppBanner;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@@ -23,7 +22,6 @@ public class ServerMain {
|
|||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(ServerMain.class)
|
ConfigurableApplicationContext context = new SpringApplicationBuilder(ServerMain.class)
|
||||||
.logStartupInfo(false)
|
.logStartupInfo(false)
|
||||||
.banner(new AppBanner())
|
|
||||||
.run(args);
|
.run(args);
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
Integer port = context.getBean(ServerProperties.class).getPort();
|
Integer port = context.getBean(ServerProperties.class).getPort();
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
package cn.keking.config;
|
|
||||||
|
|
||||||
import org.springframework.boot.Banner;
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author kl (http://kailing.pub)
|
|
||||||
* @since 2021/2/8
|
|
||||||
*/
|
|
||||||
public class AppBanner implements Banner {
|
|
||||||
@Override
|
|
||||||
public void printBanner(Environment environment, Class<?> sourceClass, PrintStream out) {
|
|
||||||
out.println(
|
|
||||||
" _ _ ______ _ _ __ __ _ \n" +
|
|
||||||
" | | | | | ____| (_) | | \\ \\ / / (_) \n" +
|
|
||||||
" | | __ | | __ | |__ _ | | ___ \\ \\ / / _ ___ __ __\n" +
|
|
||||||
" | |/ / | |/ / | __| | | | | / _ \\ \\ \\/ / | | / _ \\ \\ \\ /\\ / /\n" +
|
|
||||||
" | < | < | | | | | | | __/ \\ / | | | __/ \\ V V / \n" +
|
|
||||||
" |_|\\_\\ |_|\\_\\ |_| |_| |_| \\___| \\/ |_| \\___| \\_/\\_/ \n" +
|
|
||||||
" \n" +
|
|
||||||
" => Spring Boot :: (v2.4.2) QQ1 :: 613025121\n" +
|
|
||||||
" => kkFileView :: (v4.0.0) QQ2 :: 484680571\n" +
|
|
||||||
" => github :: https://github.com/kekingcn/kkFileView\n" +
|
|
||||||
" => gitee :: https://gitee.com/kekingcn/file-online-preview\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,8 +6,8 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: chenjh
|
* @author: chenjh
|
||||||
@@ -33,9 +33,15 @@ public class ConfigConstants {
|
|||||||
private static String ftpControlEncoding;
|
private static String ftpControlEncoding;
|
||||||
private static String baseUrl;
|
private static String baseUrl;
|
||||||
private static String fileDir = ConfigUtils.getHomePath() + File.separator + "file" + File.separator;
|
private static String fileDir = ConfigUtils.getHomePath() + File.separator + "file" + File.separator;
|
||||||
|
private static String localPreviewDir;
|
||||||
private static CopyOnWriteArraySet<String> trustHostSet;
|
private static CopyOnWriteArraySet<String> trustHostSet;
|
||||||
|
private static String pdfPresentationModeDisable;
|
||||||
|
private static String pdfOpenFileDisable;
|
||||||
|
private static String pdfPrintDisable;
|
||||||
private static String pdfDownloadDisable;
|
private static String pdfDownloadDisable;
|
||||||
|
private static String pdfBookmarkDisable;
|
||||||
private static Boolean fileUploadDisable;
|
private static Boolean fileUploadDisable;
|
||||||
|
private static String tifPreviewType;
|
||||||
|
|
||||||
public static final String DEFAULT_CACHE_ENABLED = "true";
|
public static final String DEFAULT_CACHE_ENABLED = "true";
|
||||||
public static final String DEFAULT_TXT_TYPE = "txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,log,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd";
|
public static final String DEFAULT_TXT_TYPE = "txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,log,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd";
|
||||||
@@ -47,10 +53,15 @@ public class ConfigConstants {
|
|||||||
public static final String DEFAULT_FTP_CONTROL_ENCODING = "UTF-8";
|
public static final String DEFAULT_FTP_CONTROL_ENCODING = "UTF-8";
|
||||||
public static final String DEFAULT_BASE_URL = "default";
|
public static final String DEFAULT_BASE_URL = "default";
|
||||||
public static final String DEFAULT_FILE_DIR_VALUE = "default";
|
public static final String DEFAULT_FILE_DIR_VALUE = "default";
|
||||||
|
public static final String DEFAULT_LOCAL_PREVIEW_DIR_VALUE = "default";
|
||||||
public static final String DEFAULT_TRUST_HOST = "default";
|
public static final String DEFAULT_TRUST_HOST = "default";
|
||||||
|
public static final String DEFAULT_PDF_PRESENTATION_MODE_DISABLE = "true";
|
||||||
|
public static final String DEFAULT_PDF_OPEN_FILE_DISABLE = "true";
|
||||||
|
public static final String DEFAULT_PDF_PRINT_DISABLE = "true";
|
||||||
public static final String DEFAULT_PDF_DOWNLOAD_DISABLE = "true";
|
public static final String DEFAULT_PDF_DOWNLOAD_DISABLE = "true";
|
||||||
|
public static final String DEFAULT_PDF_BOOKMARK_DISABLE = "true";
|
||||||
public static final String DEFAULT_FILE_UPLOAD_DISABLE = "false";
|
public static final String DEFAULT_FILE_UPLOAD_DISABLE = "false";
|
||||||
|
public static final String DEFAULT_TIF_PREVIEW_TYPE = "tif";
|
||||||
|
|
||||||
public static Boolean isCacheEnabled() {
|
public static Boolean isCacheEnabled() {
|
||||||
return cacheEnabled;
|
return cacheEnabled;
|
||||||
@@ -203,6 +214,24 @@ public class ConfigConstants {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getLocalPreviewDir() {
|
||||||
|
return localPreviewDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Value("${local.preview.dir:default}")
|
||||||
|
public void setLocalPreviewDir(String localPreviewDir) {
|
||||||
|
setLocalPreviewDirValue(localPreviewDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setLocalPreviewDirValue(String localPreviewDir) {
|
||||||
|
if (!DEFAULT_LOCAL_PREVIEW_DIR_VALUE.equals(localPreviewDir)) {
|
||||||
|
if (!localPreviewDir.endsWith(File.separator)) {
|
||||||
|
localPreviewDir = localPreviewDir + File.separator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ConfigConstants.localPreviewDir = localPreviewDir;
|
||||||
|
}
|
||||||
|
|
||||||
@Value("${trust.host:default}")
|
@Value("${trust.host:default}")
|
||||||
public void setTrustHost(String trustHost) {
|
public void setTrustHost(String trustHost) {
|
||||||
setTrustHostValue(trustHost);
|
setTrustHostValue(trustHost);
|
||||||
@@ -228,11 +257,46 @@ public class ConfigConstants {
|
|||||||
ConfigConstants.trustHostSet = trustHostSet;
|
ConfigConstants.trustHostSet = trustHostSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getPdfPresentationModeDisable() {
|
||||||
|
return pdfPresentationModeDisable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Value("${pdf.presentationMode.disable:true}")
|
||||||
|
public void setPdfPresentationModeDisable(String pdfPresentationModeDisable) {
|
||||||
|
setPdfPresentationModeDisableValue(pdfPresentationModeDisable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setPdfPresentationModeDisableValue(String pdfPresentationModeDisable) {
|
||||||
|
ConfigConstants.pdfPresentationModeDisable = pdfPresentationModeDisable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getPdfOpenFileDisable() {
|
||||||
|
return pdfOpenFileDisable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Value("${pdf.openFile.disable:true}")
|
||||||
|
public void setPdfOpenFileDisable(String pdfOpenFileDisable) {
|
||||||
|
setPdfOpenFileDisableValue(pdfOpenFileDisable);
|
||||||
|
}
|
||||||
|
public static void setPdfOpenFileDisableValue(String pdfOpenFileDisable) {
|
||||||
|
ConfigConstants.pdfOpenFileDisable = pdfOpenFileDisable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getPdfPrintDisable() {
|
||||||
|
return pdfPrintDisable;
|
||||||
|
}
|
||||||
|
@Value("${pdf.print.disable:true}")
|
||||||
|
public void setPdfPrintDisable(String pdfPrintDisable) {
|
||||||
|
setPdfPrintDisableValue(pdfPrintDisable);
|
||||||
|
}
|
||||||
|
public static void setPdfPrintDisableValue(String pdfPrintDisable) {
|
||||||
|
ConfigConstants.pdfPrintDisable = pdfPrintDisable;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getPdfDownloadDisable() {
|
public static String getPdfDownloadDisable() {
|
||||||
return pdfDownloadDisable;
|
return pdfDownloadDisable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Value("${pdf.download.disable:true}")
|
@Value("${pdf.download.disable:true}")
|
||||||
public void setPdfDownloadDisable(String pdfDownloadDisable) {
|
public void setPdfDownloadDisable(String pdfDownloadDisable) {
|
||||||
setPdfDownloadDisableValue(pdfDownloadDisable);
|
setPdfDownloadDisableValue(pdfDownloadDisable);
|
||||||
@@ -241,6 +305,17 @@ public class ConfigConstants {
|
|||||||
ConfigConstants.pdfDownloadDisable = pdfDownloadDisable;
|
ConfigConstants.pdfDownloadDisable = pdfDownloadDisable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getPdfBookmarkDisable() {
|
||||||
|
return pdfBookmarkDisable;
|
||||||
|
}
|
||||||
|
@Value("${pdf.bookmark.disable:true}")
|
||||||
|
public void setPdfBookmarkDisable(String pdfBookmarkDisable) {
|
||||||
|
setPdfBookmarkDisableValue(pdfBookmarkDisable);
|
||||||
|
}
|
||||||
|
public static void setPdfBookmarkDisableValue(String pdfBookmarkDisable) {
|
||||||
|
ConfigConstants.pdfBookmarkDisable = pdfBookmarkDisable;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getOfficePreviewSwitchDisabled() {
|
public static String getOfficePreviewSwitchDisabled() {
|
||||||
return officePreviewSwitchDisabled;
|
return officePreviewSwitchDisabled;
|
||||||
}
|
}
|
||||||
@@ -257,11 +332,25 @@ public class ConfigConstants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Value("${file.upload.disable:false}")
|
@Value("${file.upload.disable:false}")
|
||||||
public static void setFileUploadDisable(Boolean fileUploadDisable) {
|
public void setFileUploadDisable(Boolean fileUploadDisable) {
|
||||||
setFileUploadDisableValue(fileUploadDisable);
|
setFileUploadDisableValue(fileUploadDisable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFileUploadDisableValue(Boolean fileUploadDisable) {
|
public static void setFileUploadDisableValue(Boolean fileUploadDisable) {
|
||||||
ConfigConstants.fileUploadDisable = fileUploadDisable;
|
ConfigConstants.fileUploadDisable = fileUploadDisable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getTifPreviewType() {
|
||||||
|
return tifPreviewType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Value("${tif.preview.type:tif}")
|
||||||
|
public void setTifPreviewType(String tifPreviewType) {
|
||||||
|
setTifPreviewTypeValue(tifPreviewType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setTifPreviewTypeValue(String tifPreviewType) {
|
||||||
|
ConfigConstants.tifPreviewType = tifPreviewType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,14 @@ public class ConfigRefreshComponent {
|
|||||||
String configFilePath = ConfigUtils.getCustomizedConfigPath();
|
String configFilePath = ConfigUtils.getCustomizedConfigPath();
|
||||||
String baseUrl;
|
String baseUrl;
|
||||||
String trustHost;
|
String trustHost;
|
||||||
|
String pdfPresentationModeDisable;
|
||||||
|
String pdfOpenFileDisable;
|
||||||
|
String pdfPrintDisable;
|
||||||
String pdfDownloadDisable;
|
String pdfDownloadDisable;
|
||||||
|
String pdfBookmarkDisable;
|
||||||
boolean fileUploadDisable;
|
boolean fileUploadDisable;
|
||||||
|
String tifPreviewType;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
FileReader fileReader = new FileReader(configFilePath);
|
FileReader fileReader = new FileReader(configFilePath);
|
||||||
BufferedReader bufferedReader = new BufferedReader(fileReader);
|
BufferedReader bufferedReader = new BufferedReader(fileReader);
|
||||||
@@ -66,8 +72,14 @@ public class ConfigRefreshComponent {
|
|||||||
mediaArray = media.split(",");
|
mediaArray = media.split(",");
|
||||||
baseUrl = properties.getProperty("base.url", ConfigConstants.DEFAULT_BASE_URL);
|
baseUrl = properties.getProperty("base.url", ConfigConstants.DEFAULT_BASE_URL);
|
||||||
trustHost = properties.getProperty("trust.host", ConfigConstants.DEFAULT_TRUST_HOST);
|
trustHost = properties.getProperty("trust.host", ConfigConstants.DEFAULT_TRUST_HOST);
|
||||||
|
pdfPresentationModeDisable = properties.getProperty("pdf.presentationMode.disable", ConfigConstants.DEFAULT_PDF_PRESENTATION_MODE_DISABLE);
|
||||||
|
pdfOpenFileDisable = properties.getProperty("pdf.openFile.disable", ConfigConstants.DEFAULT_PDF_OPEN_FILE_DISABLE);
|
||||||
|
pdfPrintDisable = properties.getProperty("pdf.print.disable", ConfigConstants.DEFAULT_PDF_PRINT_DISABLE);
|
||||||
pdfDownloadDisable = properties.getProperty("pdf.download.disable", ConfigConstants.DEFAULT_PDF_DOWNLOAD_DISABLE);
|
pdfDownloadDisable = properties.getProperty("pdf.download.disable", ConfigConstants.DEFAULT_PDF_DOWNLOAD_DISABLE);
|
||||||
|
pdfBookmarkDisable = properties.getProperty("pdf.bookmark.disable", ConfigConstants.DEFAULT_PDF_BOOKMARK_DISABLE);
|
||||||
fileUploadDisable = Boolean.parseBoolean(properties.getProperty("file.upload.disable", ConfigConstants.DEFAULT_FILE_UPLOAD_DISABLE));
|
fileUploadDisable = Boolean.parseBoolean(properties.getProperty("file.upload.disable", ConfigConstants.DEFAULT_FILE_UPLOAD_DISABLE));
|
||||||
|
tifPreviewType = properties.getProperty("tif.preview.type", ConfigConstants.DEFAULT_TIF_PREVIEW_TYPE);
|
||||||
|
|
||||||
ConfigConstants.setCacheEnabledValueValue(cacheEnabled);
|
ConfigConstants.setCacheEnabledValueValue(cacheEnabled);
|
||||||
ConfigConstants.setSimTextValue(textArray);
|
ConfigConstants.setSimTextValue(textArray);
|
||||||
ConfigConstants.setMediaValue(mediaArray);
|
ConfigConstants.setMediaValue(mediaArray);
|
||||||
@@ -78,8 +90,13 @@ public class ConfigRefreshComponent {
|
|||||||
ConfigConstants.setBaseUrlValue(baseUrl);
|
ConfigConstants.setBaseUrlValue(baseUrl);
|
||||||
ConfigConstants.setTrustHostValue(trustHost);
|
ConfigConstants.setTrustHostValue(trustHost);
|
||||||
ConfigConstants.setOfficePreviewSwitchDisabledValue(officePreviewSwitchDisabled);
|
ConfigConstants.setOfficePreviewSwitchDisabledValue(officePreviewSwitchDisabled);
|
||||||
|
ConfigConstants.setPdfPresentationModeDisableValue(pdfPresentationModeDisable);
|
||||||
|
ConfigConstants.setPdfOpenFileDisableValue(pdfOpenFileDisable);
|
||||||
|
ConfigConstants.setPdfPrintDisableValue(pdfPrintDisable);
|
||||||
ConfigConstants.setPdfDownloadDisableValue(pdfDownloadDisable);
|
ConfigConstants.setPdfDownloadDisableValue(pdfDownloadDisable);
|
||||||
|
ConfigConstants.setPdfBookmarkDisableValue(pdfBookmarkDisable);
|
||||||
ConfigConstants.setFileUploadDisableValue(fileUploadDisable);
|
ConfigConstants.setFileUploadDisableValue(fileUploadDisable);
|
||||||
|
ConfigConstants.setTifPreviewTypeValue(tifPreviewType);
|
||||||
setWatermarkConfig(properties);
|
setWatermarkConfig(properties);
|
||||||
bufferedReader.close();
|
bufferedReader.close();
|
||||||
fileReader.close();
|
fileReader.close();
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
package cn.keking.config;
|
package cn.keking.config;
|
||||||
|
|
||||||
|
import cn.keking.web.filter.*;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: chenjh
|
* @author: chenjh
|
||||||
* @since: 2019/4/16 20:04
|
* @since: 2019/4/16 20:04
|
||||||
@@ -23,4 +29,63 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
LOGGER.info("Add resource locations: {}", filePath);
|
LOGGER.info("Add resource locations: {}", filePath);
|
||||||
registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/","classpath:/resources/","classpath:/static/","classpath:/public/","file:" + filePath);
|
registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/","classpath:/resources/","classpath:/static/","classpath:/public/","file:" + filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public FilterRegistrationBean<ChinesePathFilter> getChinesePathFilter() {
|
||||||
|
ChinesePathFilter filter = new ChinesePathFilter();
|
||||||
|
FilterRegistrationBean<ChinesePathFilter> registrationBean = new FilterRegistrationBean<>();
|
||||||
|
registrationBean.setFilter(filter);
|
||||||
|
return registrationBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public FilterRegistrationBean<TrustHostFilter> getTrustHostFilter() {
|
||||||
|
Set<String> filterUri = new HashSet<>();
|
||||||
|
filterUri.add("/onlinePreview");
|
||||||
|
filterUri.add("/picturesPreview");
|
||||||
|
TrustHostFilter filter = new TrustHostFilter();
|
||||||
|
FilterRegistrationBean<TrustHostFilter> registrationBean = new FilterRegistrationBean<>();
|
||||||
|
registrationBean.setFilter(filter);
|
||||||
|
registrationBean.setUrlPatterns(filterUri);
|
||||||
|
return registrationBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public FilterRegistrationBean<TrustDirFilter> getTrustDirFilter() {
|
||||||
|
Set<String> filterUri = new HashSet<>();
|
||||||
|
filterUri.add("/onlinePreview");
|
||||||
|
filterUri.add("/picturesPreview");
|
||||||
|
filterUri.add("/getCorsFile");
|
||||||
|
TrustDirFilter filter = new TrustDirFilter();
|
||||||
|
FilterRegistrationBean<TrustDirFilter> registrationBean = new FilterRegistrationBean<>();
|
||||||
|
registrationBean.setFilter(filter);
|
||||||
|
registrationBean.setUrlPatterns(filterUri);
|
||||||
|
return registrationBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public FilterRegistrationBean<BaseUrlFilter> getBaseUrlFilter() {
|
||||||
|
Set<String> filterUri = new HashSet<>();
|
||||||
|
filterUri.add("/index");
|
||||||
|
filterUri.add("/onlinePreview");
|
||||||
|
filterUri.add("/picturesPreview");
|
||||||
|
BaseUrlFilter filter = new BaseUrlFilter();
|
||||||
|
FilterRegistrationBean<BaseUrlFilter> registrationBean = new FilterRegistrationBean<>();
|
||||||
|
registrationBean.setFilter(filter);
|
||||||
|
registrationBean.setUrlPatterns(filterUri);
|
||||||
|
return registrationBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public FilterRegistrationBean<AttributeSetFilter> getWatermarkConfigFilter() {
|
||||||
|
Set<String> filterUri = new HashSet<>();
|
||||||
|
filterUri.add("/index");
|
||||||
|
filterUri.add("/onlinePreview");
|
||||||
|
filterUri.add("/picturesPreview");
|
||||||
|
AttributeSetFilter filter = new AttributeSetFilter();
|
||||||
|
FilterRegistrationBean<AttributeSetFilter> registrationBean = new FilterRegistrationBean<>();
|
||||||
|
registrationBean.setFilter(filter);
|
||||||
|
registrationBean.setUrlPatterns(filterUri);
|
||||||
|
return registrationBean;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package cn.keking.model;
|
package cn.keking.model;
|
||||||
|
|
||||||
import cn.keking.config.ConfigConstants;
|
import cn.keking.config.ConfigConstants;
|
||||||
|
import org.artofsolving.jodconverter.model.FileProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by kl on 2018/1/17.
|
* Created by kl on 2018/1/17.
|
||||||
@@ -13,7 +14,11 @@ public class FileAttribute {
|
|||||||
private String name;
|
private String name;
|
||||||
private String url;
|
private String url;
|
||||||
private String fileKey;
|
private String fileKey;
|
||||||
|
private String filePassword;
|
||||||
|
private String userToken;
|
||||||
private String officePreviewType = ConfigConstants.getOfficePreviewType();
|
private String officePreviewType = ConfigConstants.getOfficePreviewType();
|
||||||
|
private String tifPreviewType;
|
||||||
|
private Boolean skipDownLoad = false;
|
||||||
|
|
||||||
public FileAttribute() {
|
public FileAttribute() {
|
||||||
}
|
}
|
||||||
@@ -33,6 +38,12 @@ public class FileAttribute {
|
|||||||
this.officePreviewType = officePreviewType;
|
this.officePreviewType = officePreviewType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FileProperties toFileProperties() {
|
||||||
|
FileProperties fileProperties = new FileProperties();
|
||||||
|
fileProperties.setFilePassword(filePassword);
|
||||||
|
return fileProperties;
|
||||||
|
}
|
||||||
|
|
||||||
public String getFileKey() {
|
public String getFileKey() {
|
||||||
return fileKey;
|
return fileKey;
|
||||||
}
|
}
|
||||||
@@ -41,6 +52,22 @@ public class FileAttribute {
|
|||||||
this.fileKey = fileKey;
|
this.fileKey = fileKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFilePassword() {
|
||||||
|
return filePassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilePassword(String filePassword) {
|
||||||
|
this.filePassword = filePassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserToken() {
|
||||||
|
return userToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserToken(String userToken) {
|
||||||
|
this.userToken = userToken;
|
||||||
|
}
|
||||||
|
|
||||||
public String getOfficePreviewType() {
|
public String getOfficePreviewType() {
|
||||||
return officePreviewType;
|
return officePreviewType;
|
||||||
}
|
}
|
||||||
@@ -80,4 +107,21 @@ public class FileAttribute {
|
|||||||
public void setUrl(String url) {
|
public void setUrl(String url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getSkipDownLoad() {
|
||||||
|
return skipDownLoad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSkipDownLoad(Boolean skipDownLoad) {
|
||||||
|
this.skipDownLoad = skipDownLoad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTifPreviewType() {
|
||||||
|
return tifPreviewType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTifPreviewType(String previewType) {
|
||||||
|
this.tifPreviewType = previewType;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ public enum FileType {
|
|||||||
OFD("ofdFilePreviewImpl");
|
OFD("ofdFilePreviewImpl");
|
||||||
|
|
||||||
|
|
||||||
private static final String[] OFFICE_TYPES = {"docx", "wps", "doc", "xls", "xlsx", "ppt", "pptx"};
|
private static final String[] OFFICE_TYPES = {"docx", "wps", "doc", "docm", "xls", "xlsx", "csv" ,"xlsm", "ppt", "pptx", "vsd", "rtf", "odt", "wmf", "emf", "dps", "et", "ods", "ots", "tsv", "odp", "otp", "sxi", "ott", "vsdx", "fodt", "fods", "xltx","tga","psd"};
|
||||||
private static final String[] PICTURE_TYPES = {"jpg", "jpeg", "png", "gif", "bmp", "ico", "raw"};
|
private static final String[] PICTURE_TYPES = {"jpg", "jpeg", "png", "gif", "bmp", "ico", "jfif", "webp"};
|
||||||
private static final String[] ARCHIVE_TYPES = {"rar", "zip", "jar", "7-zip", "tar", "gzip", "7z"};
|
private static final String[] ARCHIVE_TYPES = {"rar", "zip", "jar", "7-zip", "tar", "gzip", "7z"};
|
||||||
private static final String[] TIFF_TYPES = {"tif", "tiff"};
|
private static final String[] TIFF_TYPES = {"tif", "tiff"};
|
||||||
private static final String[] OFD_TYPES = {"ofd"};
|
private static final String[] OFD_TYPES = {"ofd"};
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -149,7 +149,7 @@ public class FileHandlerService {
|
|||||||
sb.append(line);
|
sb.append(line);
|
||||||
}
|
}
|
||||||
// 添加sheet控制头
|
// 添加sheet控制头
|
||||||
sb.append("<script src=\"js/jquery-3.0.0.min.js\" type=\"text/javascript\"></script>");
|
sb.append("<script src=\"js/jquery-3.6.1.min.js\" type=\"text/javascript\"></script>");
|
||||||
sb.append("<script src=\"js/excel.header.js\" type=\"text/javascript\"></script>");
|
sb.append("<script src=\"js/excel.header.js\" type=\"text/javascript\"></script>");
|
||||||
sb.append("<link rel=\"stylesheet\" href=\"bootstrap/css/bootstrap.min.css\">");
|
sb.append("<link rel=\"stylesheet\" href=\"bootstrap/css/bootstrap.min.css\">");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -270,9 +270,13 @@ public class FileHandlerService {
|
|||||||
type = FileType.typeFromUrl(url);
|
type = FileType.typeFromUrl(url);
|
||||||
suffix = WebUtils.suffixFromUrl(url);
|
suffix = WebUtils.suffixFromUrl(url);
|
||||||
}
|
}
|
||||||
|
if (url.contains("?fileKey=")) {
|
||||||
|
attribute.setSkipDownLoad(true);
|
||||||
|
}
|
||||||
attribute.setType(type);
|
attribute.setType(type);
|
||||||
attribute.setName(fileName);
|
attribute.setName(fileName);
|
||||||
attribute.setSuffix(suffix);
|
attribute.setSuffix(suffix);
|
||||||
|
url = WebUtils.encodeUrlFileName(url);
|
||||||
attribute.setUrl(url);
|
attribute.setUrl(url);
|
||||||
if (req != null) {
|
if (req != null) {
|
||||||
String officePreviewType = req.getParameter("officePreviewType");
|
String officePreviewType = req.getParameter("officePreviewType");
|
||||||
@@ -283,7 +287,23 @@ public class FileHandlerService {
|
|||||||
if (StringUtils.hasText(fileKey)) {
|
if (StringUtils.hasText(fileKey)) {
|
||||||
attribute.setFileKey(fileKey);
|
attribute.setFileKey(fileKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String tifPreviewType = req.getParameter("tifPreviewType");
|
||||||
|
if (StringUtils.hasText(tifPreviewType)) {
|
||||||
|
attribute.setTifPreviewType(tifPreviewType);
|
||||||
|
}
|
||||||
|
|
||||||
|
String filePassword = req.getParameter("filePassword");
|
||||||
|
if (StringUtils.hasText(filePassword)) {
|
||||||
|
attribute.setFilePassword(filePassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
String userToken = req.getParameter("userToken");
|
||||||
|
if (StringUtils.hasText(userToken)) {
|
||||||
|
attribute.setUserToken(userToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return attribute;
|
return attribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.artofsolving.jodconverter.OfficeDocumentConverter;
|
|||||||
import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration;
|
import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration;
|
||||||
import org.artofsolving.jodconverter.office.OfficeManager;
|
import org.artofsolving.jodconverter.office.OfficeManager;
|
||||||
import org.artofsolving.jodconverter.office.OfficeUtils;
|
import org.artofsolving.jodconverter.office.OfficeUtils;
|
||||||
|
import org.artofsolving.jodconverter.util.PlatformUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@@ -24,7 +25,6 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建文件转换器
|
* 创建文件转换器
|
||||||
@@ -50,7 +50,7 @@ public class OfficePluginManager {
|
|||||||
* 启动Office组件进程
|
* 启动Office组件进程
|
||||||
*/
|
*/
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void startOfficeManager(){
|
public void startOfficeManager() {
|
||||||
File officeHome = OfficeUtils.getDefaultOfficeHome();
|
File officeHome = OfficeUtils.getDefaultOfficeHome();
|
||||||
if (officeHome == null) {
|
if (officeHome == null) {
|
||||||
throw new RuntimeException("找不到office组件,请确认'office.home'配置是否有误");
|
throw new RuntimeException("找不到office组件,请确认'office.home'配置是否有误");
|
||||||
@@ -62,7 +62,7 @@ public class OfficePluginManager {
|
|||||||
try {
|
try {
|
||||||
DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration();
|
DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration();
|
||||||
configuration.setOfficeHome(officeHome);
|
configuration.setOfficeHome(officeHome);
|
||||||
String []portsString = serverPorts.split(",");
|
String[] portsString = serverPorts.split(",");
|
||||||
|
|
||||||
int[] ports = Arrays.stream(portsString).mapToInt(Integer::parseInt).toArray();
|
int[] ports = Arrays.stream(portsString).mapToInt(Integer::parseInt).toArray();
|
||||||
|
|
||||||
@@ -86,8 +86,8 @@ public class OfficePluginManager {
|
|||||||
return converter;
|
return converter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String,?> getLoadProperties() {
|
private Map<String, ?> getLoadProperties() {
|
||||||
Map<String,Object> loadProperties = new HashMap<>(10);
|
Map<String, Object> loadProperties = new HashMap<>(10);
|
||||||
loadProperties.put("Hidden", true);
|
loadProperties.put("Hidden", true);
|
||||||
loadProperties.put("ReadOnly", true);
|
loadProperties.put("ReadOnly", true);
|
||||||
loadProperties.put("UpdateDocMode", UpdateDocMode.QUIET_UPDATE);
|
loadProperties.put("UpdateDocMode", UpdateDocMode.QUIET_UPDATE);
|
||||||
@@ -97,9 +97,8 @@ public class OfficePluginManager {
|
|||||||
|
|
||||||
private boolean killProcess() {
|
private boolean killProcess() {
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
Properties props = System.getProperties();
|
|
||||||
try {
|
try {
|
||||||
if (props.getProperty("os.name").toLowerCase().contains("windows")) {
|
if (PlatformUtils.isWindows()) {
|
||||||
Process p = Runtime.getRuntime().exec("cmd /c tasklist ");
|
Process p = Runtime.getRuntime().exec("cmd /c tasklist ");
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
InputStream os = p.getInputStream();
|
InputStream os = p.getInputStream();
|
||||||
@@ -112,8 +111,22 @@ public class OfficePluginManager {
|
|||||||
Runtime.getRuntime().exec("taskkill /im " + "soffice.bin" + " /f");
|
Runtime.getRuntime().exec("taskkill /im " + "soffice.bin" + " /f");
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
|
} else if (PlatformUtils.isLinux()) {
|
||||||
|
Process p = Runtime.getRuntime().exec(new String[]{"sh", "-c", "ps -ef | grep " + "soffice.bin" + " |grep -v grep | wc -l"});
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
InputStream os = p.getInputStream();
|
||||||
|
byte[] b = new byte[256];
|
||||||
|
while (os.read(b) > 0) {
|
||||||
|
baos.write(b);
|
||||||
|
}
|
||||||
|
String s = baos.toString();
|
||||||
|
if (!s.startsWith("0")) {
|
||||||
|
String[] cmd = {"sh", "-c", "ps -ef | grep soffice.bin | grep -v grep | awk '{print \"kill -9 \"$2}' | sh"};
|
||||||
|
Runtime.getRuntime().exec(cmd);
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Process p = Runtime.getRuntime().exec(new String[]{"sh","-c","ps -ef | grep " + "soffice.bin"});
|
Process p = Runtime.getRuntime().exec(new String[]{"sh", "-c", "ps -ef | grep " + "soffice.bin"});
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
InputStream os = p.getInputStream();
|
InputStream os = p.getInputStream();
|
||||||
byte[] b = new byte[256];
|
byte[] b = new byte[256];
|
||||||
@@ -122,7 +135,7 @@ public class OfficePluginManager {
|
|||||||
}
|
}
|
||||||
String s = baos.toString();
|
String s = baos.toString();
|
||||||
if (StringUtils.ordinalIndexOf(s, "soffice.bin", 3) > 0) {
|
if (StringUtils.ordinalIndexOf(s, "soffice.bin", 3) > 0) {
|
||||||
String[] cmd ={"sh","-c","kill -15 `ps -ef|grep " + "soffice.bin" + "|awk 'NR==1{print $2}'`"};
|
String[] cmd = {"sh", "-c", "kill -15 `ps -ef|grep " + "soffice.bin" + "|awk 'NR==1{print $2}'`"};
|
||||||
Runtime.getRuntime().exec(cmd);
|
Runtime.getRuntime().exec(cmd);
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
@@ -134,7 +147,7 @@ public class OfficePluginManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
public void destroyOfficeManager(){
|
public void destroyOfficeManager() {
|
||||||
if (null != officeManager && officeManager.isRunning()) {
|
if (null != officeManager && officeManager.isRunning()) {
|
||||||
logger.info("Shutting down office process");
|
logger.info("Shutting down office process");
|
||||||
officeManager.stop();
|
officeManager.stop();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package cn.keking.service;
|
package cn.keking.service;
|
||||||
|
|
||||||
|
import cn.keking.model.FileAttribute;
|
||||||
import org.artofsolving.jodconverter.OfficeDocumentConverter;
|
import org.artofsolving.jodconverter.OfficeDocumentConverter;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -20,22 +21,23 @@ public class OfficeToPdfService {
|
|||||||
this.officePluginManager = officePluginManager;
|
this.officePluginManager = officePluginManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openOfficeToPDF(String inputFilePath, String outputFilePath) {
|
public void openOfficeToPDF(String inputFilePath, String outputFilePath, FileAttribute fileAttribute) {
|
||||||
office2pdf(inputFilePath, outputFilePath);
|
office2pdf(inputFilePath, outputFilePath, fileAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void converterFile(File inputFile, String outputFilePath_end, OfficeDocumentConverter converter) {
|
public static void converterFile(File inputFile, String outputFilePath_end, OfficeDocumentConverter converter, FileAttribute fileAttribute) {
|
||||||
File outputFile = new File(outputFilePath_end);
|
File outputFile = new File(outputFilePath_end);
|
||||||
// 假如目标路径不存在,则新建该路径
|
// 假如目标路径不存在,则新建该路径
|
||||||
if (!outputFile.getParentFile().exists() && !outputFile.getParentFile().mkdirs()) {
|
if (!outputFile.getParentFile().exists() && !outputFile.getParentFile().mkdirs()) {
|
||||||
logger.error("创建目录【{}】失败,请检查目录权限!",outputFilePath_end);
|
logger.error("创建目录【{}】失败,请检查目录权限!",outputFilePath_end);
|
||||||
}
|
}
|
||||||
converter.convert(inputFile, outputFile);
|
|
||||||
|
converter.convert(inputFile, outputFile, fileAttribute.toFileProperties());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void office2pdf(String inputFilePath, String outputFilePath) {
|
public void office2pdf(String inputFilePath, String outputFilePath, FileAttribute fileAttribute) {
|
||||||
OfficeDocumentConverter converter = officePluginManager.getDocumentConverter();
|
OfficeDocumentConverter converter = officePluginManager.getDocumentConverter();
|
||||||
if (null != inputFilePath) {
|
if (null != inputFilePath) {
|
||||||
File inputFile = new File(inputFilePath);
|
File inputFile = new File(inputFilePath);
|
||||||
@@ -45,12 +47,12 @@ public class OfficeToPdfService {
|
|||||||
String outputFilePath_end = getOutputFilePath(inputFilePath);
|
String outputFilePath_end = getOutputFilePath(inputFilePath);
|
||||||
if (inputFile.exists()) {
|
if (inputFile.exists()) {
|
||||||
// 找不到源文件, 则返回
|
// 找不到源文件, 则返回
|
||||||
converterFile(inputFile, outputFilePath_end,converter);
|
converterFile(inputFile, outputFilePath_end, converter, fileAttribute);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (inputFile.exists()) {
|
if (inputFile.exists()) {
|
||||||
// 找不到源文件, 则返回
|
// 找不到源文件, 则返回
|
||||||
converterFile(inputFile, outputFilePath, converter);
|
converterFile(inputFile, outputFilePath, converter, fileAttribute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package cn.keking.service.cache.impl;
|
|||||||
import cn.keking.service.cache.CacheService;
|
import cn.keking.service.cache.CacheService;
|
||||||
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
|
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
|
||||||
import com.googlecode.concurrentlinkedhashmap.Weighers;
|
import com.googlecode.concurrentlinkedhashmap.Weighers;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ public class CacheServiceRocksDBImpl implements CacheService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public Map<String, String> getMediaConvertCache() {
|
public Map<String, String> getMediaConvertCache() {
|
||||||
Map<String, String> result = new HashMap<>();
|
Map<String, String> result = new HashMap<>();
|
||||||
try{
|
try{
|
||||||
@@ -199,6 +200,7 @@ public class CacheServiceRocksDBImpl implements CacheService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public String getMediaConvertCache(String key) {
|
public String getMediaConvertCache(String key) {
|
||||||
String result = "";
|
String result = "";
|
||||||
try{
|
try{
|
||||||
|
|||||||
@@ -40,16 +40,7 @@ public class CompressFilePreviewImpl implements FilePreview {
|
|||||||
return otherFilePreview.notSupportedFile(model, fileAttribute, response.getMsg());
|
return otherFilePreview.notSupportedFile(model, fileAttribute, response.getMsg());
|
||||||
}
|
}
|
||||||
String filePath = response.getContent();
|
String filePath = response.getContent();
|
||||||
if ("zip".equalsIgnoreCase(suffix) || "jar".equalsIgnoreCase(suffix) || "gzip".equalsIgnoreCase(suffix)) {
|
fileTree = compressFileReader.unRar(filePath, fileName);
|
||||||
fileTree = compressFileReader.readZipFile(filePath, fileName);
|
|
||||||
} else if ("rar".equalsIgnoreCase(suffix)) {
|
|
||||||
fileTree = compressFileReader.unRar(filePath, fileName);
|
|
||||||
} else if ("7z".equalsIgnoreCase(suffix)) {
|
|
||||||
fileTree = compressFileReader.read7zFile(filePath, fileName);
|
|
||||||
}
|
|
||||||
if (fileTree != null && !"null".equals(fileTree) && ConfigConstants.isCacheEnabled()) {
|
|
||||||
fileHandlerService.addConvertedFile(fileName, fileTree);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
fileTree = fileHandlerService.getConvertedFile(fileName);
|
fileTree = fileHandlerService.getConvertedFile(fileName);
|
||||||
}
|
}
|
||||||
@@ -57,7 +48,7 @@ public class CompressFilePreviewImpl implements FilePreview {
|
|||||||
model.addAttribute("fileTree", fileTree);
|
model.addAttribute("fileTree", fileTree);
|
||||||
return COMPRESS_FILE_PREVIEW_PAGE;
|
return COMPRESS_FILE_PREVIEW_PAGE;
|
||||||
} else {
|
} else {
|
||||||
return otherFilePreview.notSupportedFile(model, fileAttribute, "压缩文件类型不受支持,尝试在压缩的时候选择RAR4格式");
|
return otherFilePreview.notSupportedFile(model, fileAttribute, "压缩文件类型不受支持");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ package cn.keking.service.impl;
|
|||||||
import cn.keking.config.ConfigConstants;
|
import cn.keking.config.ConfigConstants;
|
||||||
import cn.keking.model.FileAttribute;
|
import cn.keking.model.FileAttribute;
|
||||||
import cn.keking.model.ReturnResponse;
|
import cn.keking.model.ReturnResponse;
|
||||||
import cn.keking.service.FilePreview;
|
|
||||||
import cn.keking.utils.DownloadUtils;
|
|
||||||
import cn.keking.service.FileHandlerService;
|
import cn.keking.service.FileHandlerService;
|
||||||
|
import cn.keking.service.FilePreview;
|
||||||
import cn.keking.service.OfficeToPdfService;
|
import cn.keking.service.OfficeToPdfService;
|
||||||
|
import cn.keking.utils.DownloadUtils;
|
||||||
|
import cn.keking.utils.OfficeUtils;
|
||||||
import cn.keking.web.filter.BaseUrlFilter;
|
import cn.keking.web.filter.BaseUrlFilter;
|
||||||
|
import org.artofsolving.jodconverter.office.OfficeException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@@ -42,33 +44,83 @@ public class OfficeFilePreviewImpl implements FilePreview {
|
|||||||
String baseUrl = BaseUrlFilter.getBaseUrl();
|
String baseUrl = BaseUrlFilter.getBaseUrl();
|
||||||
String suffix = fileAttribute.getSuffix();
|
String suffix = fileAttribute.getSuffix();
|
||||||
String fileName = fileAttribute.getName();
|
String fileName = fileAttribute.getName();
|
||||||
boolean isHtml = suffix.equalsIgnoreCase("xls") || suffix.equalsIgnoreCase("xlsx");
|
String filePassword = fileAttribute.getFilePassword();
|
||||||
|
String userToken = fileAttribute.getUserToken();
|
||||||
|
boolean isHtml = suffix.equalsIgnoreCase("xls") || suffix.equalsIgnoreCase("xlsx") || suffix.equalsIgnoreCase("csv");
|
||||||
String pdfName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + (isHtml ? "html" : "pdf");
|
String pdfName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + (isHtml ? "html" : "pdf");
|
||||||
String outFilePath = FILE_DIR + pdfName;
|
String cacheFileName = userToken == null ? pdfName : userToken + "_" + pdfName;
|
||||||
// 判断之前是否已转换过,如果转换过,直接返回,否则执行转换
|
String outFilePath = FILE_DIR + cacheFileName;
|
||||||
if (!fileHandlerService.listConvertedFiles().containsKey(pdfName) || !ConfigConstants.isCacheEnabled()) {
|
|
||||||
String filePath;
|
// 下载远程文件到本地,如果文件在本地已存在不会重复下载
|
||||||
ReturnResponse<String> response = DownloadUtils.downLoad(fileAttribute, null);
|
ReturnResponse<String> response = DownloadUtils.downLoad(fileAttribute, fileName);
|
||||||
if (response.isFailure()) {
|
if (response.isFailure()) {
|
||||||
return otherFilePreview.notSupportedFile(model, fileAttribute, response.getMsg());
|
return otherFilePreview.notSupportedFile(model, fileAttribute, response.getMsg());
|
||||||
|
}
|
||||||
|
String filePath = response.getContent();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 1. 缓存判断-如果文件已经进行转换过,就直接返回,否则执行转换
|
||||||
|
* 2. 缓存判断-加密文件基于userToken进行缓存,如果没有就不缓存
|
||||||
|
*/
|
||||||
|
boolean isCached = false;
|
||||||
|
boolean isUseCached = false;
|
||||||
|
boolean isPwdProtectedOffice = false;
|
||||||
|
if (ConfigConstants.isCacheEnabled()) {
|
||||||
|
// 全局开启缓存
|
||||||
|
isUseCached = true;
|
||||||
|
if (fileHandlerService.listConvertedFiles().containsKey(cacheFileName)) {
|
||||||
|
// 存在缓存
|
||||||
|
isCached = true;
|
||||||
}
|
}
|
||||||
filePath = response.getContent();
|
if (OfficeUtils.isPwdProtected(filePath)) {
|
||||||
if (StringUtils.hasText(outFilePath)) {
|
isPwdProtectedOffice = true;
|
||||||
officeToPdfService.openOfficeToPDF(filePath, outFilePath);
|
if (!StringUtils.hasLength(userToken)) {
|
||||||
if (isHtml) {
|
// 不缓存没有userToken的加密文件
|
||||||
// 对转换后的文件进行操作(改变编码方式)
|
isUseCached = false;
|
||||||
fileHandlerService.doActionConvertedFile(outFilePath);
|
|
||||||
}
|
}
|
||||||
if (ConfigConstants.isCacheEnabled()) {
|
}
|
||||||
// 加入缓存
|
} else {
|
||||||
fileHandlerService.addConvertedFile(pdfName, fileHandlerService.getRelativePath(outFilePath));
|
isPwdProtectedOffice = OfficeUtils.isPwdProtected(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isCached == false) {
|
||||||
|
// 没有缓存执行转换逻辑
|
||||||
|
if (isPwdProtectedOffice && !StringUtils.hasLength(filePassword)) {
|
||||||
|
// 加密文件需要密码
|
||||||
|
model.addAttribute("needFilePassword", true);
|
||||||
|
return EXEL_FILE_PREVIEW_PAGE;
|
||||||
|
} else {
|
||||||
|
if (StringUtils.hasText(outFilePath)) {
|
||||||
|
try {
|
||||||
|
officeToPdfService.openOfficeToPDF(filePath, outFilePath, fileAttribute);
|
||||||
|
} catch (OfficeException e) {
|
||||||
|
if (isPwdProtectedOffice && OfficeUtils.isCompatible(filePath, filePassword) == false) {
|
||||||
|
// 加密文件密码错误,提示重新输入
|
||||||
|
model.addAttribute("needFilePassword", true);
|
||||||
|
model.addAttribute("filePasswordError", true);
|
||||||
|
return EXEL_FILE_PREVIEW_PAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return otherFilePreview.notSupportedFile(model, fileAttribute, "抱歉,该文件版本不兼容,文件版本错误。");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtml) {
|
||||||
|
// 对转换后的文件进行操作(改变编码方式)
|
||||||
|
fileHandlerService.doActionConvertedFile(outFilePath);
|
||||||
|
}
|
||||||
|
if (isUseCached) {
|
||||||
|
// 加入缓存
|
||||||
|
fileHandlerService.addConvertedFile(cacheFileName, fileHandlerService.getRelativePath(outFilePath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isHtml && baseUrl != null && (OFFICE_PREVIEW_TYPE_IMAGE.equals(officePreviewType) || OFFICE_PREVIEW_TYPE_ALL_IMAGES.equals(officePreviewType))) {
|
if (!isHtml && baseUrl != null && (OFFICE_PREVIEW_TYPE_IMAGE.equals(officePreviewType) || OFFICE_PREVIEW_TYPE_ALL_IMAGES.equals(officePreviewType))) {
|
||||||
return getPreviewType(model, fileAttribute, officePreviewType, baseUrl, pdfName, outFilePath, fileHandlerService, OFFICE_PREVIEW_TYPE_IMAGE, otherFilePreview);
|
return getPreviewType(model, fileAttribute, officePreviewType, baseUrl, cacheFileName, outFilePath, fileHandlerService, OFFICE_PREVIEW_TYPE_IMAGE, otherFilePreview);
|
||||||
}
|
}
|
||||||
model.addAttribute("pdfUrl", pdfName);
|
|
||||||
|
model.addAttribute("pdfUrl", cacheFileName);
|
||||||
return isHtml ? EXEL_FILE_PREVIEW_PAGE : PDF_FILE_PREVIEW_PAGE;
|
return isHtml ? EXEL_FILE_PREVIEW_PAGE : PDF_FILE_PREVIEW_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,4 +140,5 @@ public class OfficeFilePreviewImpl implements FilePreview {
|
|||||||
return PICTURE_FILE_PREVIEW_PAGE;
|
return PICTURE_FILE_PREVIEW_PAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ import org.springframework.ui.Model;
|
|||||||
import org.springframework.web.util.HtmlUtils;
|
import org.springframework.web.util.HtmlUtils;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by kl on 2018/1/17.
|
* Created by kl on 2018/1/17.
|
||||||
@@ -28,16 +31,14 @@ public class SimTextFilePreviewImpl implements FilePreview {
|
|||||||
private static final String FILE_DIR = ConfigConstants.getFileDir();
|
private static final String FILE_DIR = ConfigConstants.getFileDir();
|
||||||
@Override
|
@Override
|
||||||
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
|
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
|
||||||
|
|
||||||
String fileName = fileAttribute.getName();
|
String fileName = fileAttribute.getName();
|
||||||
String baseUrll = FILE_DIR + fileName;
|
String filePath = FILE_DIR + fileName;
|
||||||
// String suffix = fileAttribute.getSuffix();
|
|
||||||
ReturnResponse<String> response = DownloadUtils.downLoad(fileAttribute, fileName);
|
ReturnResponse<String> response = DownloadUtils.downLoad(fileAttribute, fileName);
|
||||||
if (response.isFailure()) {
|
if (response.isFailure()) {
|
||||||
return otherFilePreview.notSupportedFile(model, fileAttribute, response.getMsg());
|
return otherFilePreview.notSupportedFile(model, fileAttribute, response.getMsg());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String fileData = HtmlUtils.htmlEscape(textData(baseUrll));
|
String fileData = HtmlUtils.htmlEscape(textData(filePath));
|
||||||
model.addAttribute("textData", Base64.encodeBase64String(fileData.getBytes()));
|
model.addAttribute("textData", Base64.encodeBase64String(fileData.getBytes()));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return otherFilePreview.notSupportedFile(model, fileAttribute, e.getLocalizedMessage());
|
return otherFilePreview.notSupportedFile(model, fileAttribute, e.getLocalizedMessage());
|
||||||
@@ -45,15 +46,16 @@ public class SimTextFilePreviewImpl implements FilePreview {
|
|||||||
return TXT_FILE_PREVIEW_PAGE;
|
return TXT_FILE_PREVIEW_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String textData(String baseUrll) throws IOException {
|
private String textData(String filePath) throws IOException {
|
||||||
File file = new File(baseUrll);
|
File file = new File(filePath);
|
||||||
if(!file.exists() || file.length() == 0) {
|
if (!file.exists() || file.length() == 0) {
|
||||||
String line="";
|
return "";
|
||||||
return line;
|
} else {
|
||||||
}else {
|
String charset = EncodingDetects.getJavaEncode(filePath);
|
||||||
String charset = EncodingDetects.getJavaEncode(baseUrll);
|
if ("ASCII".equals(charset)) {
|
||||||
System.out.println(charset);
|
charset = StandardCharsets.US_ASCII.name();
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(baseUrll), charset));
|
}
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get(filePath)), charset));
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
|
|||||||
@@ -1,38 +1,119 @@
|
|||||||
package cn.keking.service.impl;
|
package cn.keking.service.impl;
|
||||||
|
|
||||||
|
import cn.keking.config.ConfigConstants;
|
||||||
import cn.keking.model.FileAttribute;
|
import cn.keking.model.FileAttribute;
|
||||||
|
import cn.keking.model.ReturnResponse;
|
||||||
import cn.keking.service.FilePreview;
|
import cn.keking.service.FilePreview;
|
||||||
|
import cn.keking.utils.ConvertPicUtil;
|
||||||
|
import cn.keking.utils.DownloadUtils;
|
||||||
import cn.keking.utils.WebUtils;
|
import cn.keking.utils.WebUtils;
|
||||||
|
import cn.keking.web.filter.BaseUrlFilter;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tiff 图片文件处理
|
* tiff 图片文件处理
|
||||||
|
*
|
||||||
* @author kl (http://kailing.pub)
|
* @author kl (http://kailing.pub)
|
||||||
* @since 2021/2/8
|
* @since 2021/2/8
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class TiffFilePreviewImpl implements FilePreview {
|
public class TiffFilePreviewImpl implements FilePreview {
|
||||||
|
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(TiffFilePreviewImpl.class);
|
||||||
|
|
||||||
private final PictureFilePreviewImpl pictureFilePreview;
|
private final PictureFilePreviewImpl pictureFilePreview;
|
||||||
private static final String INITIALIZE_MEMORY_SIZE = "initializeMemorySize";
|
private static final String INITIALIZE_MEMORY_SIZE = "initializeMemorySize";
|
||||||
//默认初始化 50MB 内存
|
//默认初始化 50MB 内存
|
||||||
private static final long INITIALIZE_MEMORY_SIZE_VALUE_DEFAULT = 1024L * 1024 * 50;
|
private static final long INITIALIZE_MEMORY_SIZE_VALUE_DEFAULT = 1024L * 1024 * 50;
|
||||||
|
|
||||||
|
private final String fileDir = ConfigConstants.getFileDir();
|
||||||
|
|
||||||
public TiffFilePreviewImpl(PictureFilePreviewImpl pictureFilePreview) {
|
public TiffFilePreviewImpl(PictureFilePreviewImpl pictureFilePreview) {
|
||||||
this.pictureFilePreview = pictureFilePreview;
|
this.pictureFilePreview = pictureFilePreview;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
|
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
|
||||||
pictureFilePreview.filePreviewHandle(url,model,fileAttribute);
|
String tifPreviewType = ConfigConstants.getTifPreviewType();
|
||||||
String fileSize = WebUtils.getUrlParameterReg(url,INITIALIZE_MEMORY_SIZE);
|
String tifOnLinePreviewType = fileAttribute.getTifPreviewType();
|
||||||
if(StringUtils.hasText(fileSize)){
|
if (StringUtils.hasText(tifOnLinePreviewType)) {
|
||||||
model.addAttribute(INITIALIZE_MEMORY_SIZE,fileSize);
|
tifPreviewType = tifOnLinePreviewType;
|
||||||
}else {
|
}
|
||||||
model.addAttribute(INITIALIZE_MEMORY_SIZE,Long.toString(INITIALIZE_MEMORY_SIZE_VALUE_DEFAULT));
|
|
||||||
}
|
if ("tif".equalsIgnoreCase(tifPreviewType)) {
|
||||||
return TIFF_FILE_PREVIEW_PAGE;
|
|
||||||
|
pictureFilePreview.filePreviewHandle(url, model, fileAttribute);
|
||||||
|
String fileSize = WebUtils.getUrlParameterReg(url, INITIALIZE_MEMORY_SIZE);
|
||||||
|
if (StringUtils.hasText(fileSize)) {
|
||||||
|
model.addAttribute(INITIALIZE_MEMORY_SIZE, fileSize);
|
||||||
|
} else {
|
||||||
|
model.addAttribute(INITIALIZE_MEMORY_SIZE, Long.toString(INITIALIZE_MEMORY_SIZE_VALUE_DEFAULT));
|
||||||
|
}
|
||||||
|
return TIFF_FILE_PREVIEW_PAGE;
|
||||||
|
|
||||||
|
} else if ("jpg".equalsIgnoreCase(tifPreviewType) || "pdf".equalsIgnoreCase(tifPreviewType)) {
|
||||||
|
String inputFileName = url.substring(url.lastIndexOf("/") + 1);
|
||||||
|
String inputFileNamePrefix = inputFileName.substring(0, inputFileName.lastIndexOf("."));
|
||||||
|
|
||||||
|
String strLocalTif = fileDir + inputFileName;
|
||||||
|
File fileTiff = new File(strLocalTif);
|
||||||
|
// 如果本地不存在这个tif文件,则下载
|
||||||
|
if (!fileTiff.exists()) {
|
||||||
|
ReturnResponse<String> response = DownloadUtils.downLoad(fileAttribute, inputFileName);
|
||||||
|
if (response.isFailure()) {
|
||||||
|
return NOT_SUPPORTED_FILE_PAGE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String baseUrl = BaseUrlFilter.getBaseUrl();
|
||||||
|
if ("pdf".equalsIgnoreCase(tifPreviewType)) {
|
||||||
|
// 以PDF模式预览的过程
|
||||||
|
File filePdf = new File(fileDir + inputFileNamePrefix + ".pdf");
|
||||||
|
// 如果本地不存在对应的pdf,则调用转换过程。否则直接用现有的pdf文件
|
||||||
|
if (!filePdf.exists()) {
|
||||||
|
filePdf = ConvertPicUtil.convertTif2Pdf(strLocalTif, fileDir + inputFileNamePrefix + ".pdf");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果pdf已经存在,则将url路径加入到对象中,返回给页面
|
||||||
|
assert filePdf != null;
|
||||||
|
if (filePdf.exists()) {
|
||||||
|
String pdfUrl = baseUrl + inputFileNamePrefix + ".pdf";
|
||||||
|
model.addAttribute("pdfUrl", pdfUrl);
|
||||||
|
|
||||||
|
return PDF_FILE_PREVIEW_PAGE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 以JPG模式预览的过程
|
||||||
|
String strJpgFilePathName = fileDir + inputFileNamePrefix + ".jpg";
|
||||||
|
// 将tif转换为jpg,返回转换后的文件路径、文件名的list
|
||||||
|
List<String> listPic2Jpg = ConvertPicUtil.convertTif2Jpg(strLocalTif, strJpgFilePathName);
|
||||||
|
// 将返回页面的图片url的list对象
|
||||||
|
List<String> listImageUrls = new ArrayList<>();
|
||||||
|
// 循环,拼装url的list对象
|
||||||
|
for (String strJpg : listPic2Jpg) {
|
||||||
|
listImageUrls.add(baseUrl + strJpg);
|
||||||
|
}
|
||||||
|
|
||||||
|
model.addAttribute("imgUrls", listImageUrls);
|
||||||
|
model.addAttribute("currentUrl", listImageUrls.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 转换后的tif没用了,可以删掉了
|
||||||
|
if (fileTiff.exists() && !fileTiff.delete()) {
|
||||||
|
logger.error("{} 清理失败", strLocalTif);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PICTURE_FILE_PREVIEW_PAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NOT_SUPPORTED_FILE_PAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
231
server/src/main/java/cn/keking/utils/ConvertPicUtil.java
Normal file
231
server/src/main/java/cn/keking/utils/ConvertPicUtil.java
Normal file
@@ -0,0 +1,231 @@
|
|||||||
|
package cn.keking.utils;
|
||||||
|
|
||||||
|
|
||||||
|
import com.lowagie.text.Document;
|
||||||
|
import com.lowagie.text.Image;
|
||||||
|
import com.lowagie.text.Rectangle;
|
||||||
|
import com.lowagie.text.pdf.PdfWriter;
|
||||||
|
import com.lowagie.text.pdf.RandomAccessFileOrArray;
|
||||||
|
import com.lowagie.text.pdf.codec.TiffImage;
|
||||||
|
import com.sun.media.jai.codec.*;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.media.jai.JAI;
|
||||||
|
import javax.media.jai.RenderedOp;
|
||||||
|
import java.awt.image.RenderedImage;
|
||||||
|
import java.awt.image.renderable.ParameterBlock;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ConvertPicUtil {
|
||||||
|
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(ConvertPicUtil.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tif 转 JPG。
|
||||||
|
*
|
||||||
|
* @param strInputFile 输入文件的路径和文件名
|
||||||
|
* @param strOutputFile 输出文件的路径和文件名
|
||||||
|
* @return boolean 是否转换成功
|
||||||
|
*/
|
||||||
|
public static List<String> convertTif2Jpg(String strInputFile, String strOutputFile) {
|
||||||
|
List<String> listImageFiles = new ArrayList<>();
|
||||||
|
|
||||||
|
if (strInputFile == null || "".equals(strInputFile.trim())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!new File(strInputFile).exists()) {
|
||||||
|
logger.info("找不到文件【" + strInputFile + "】");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
strInputFile = strInputFile.replaceAll("\\\\", "/");
|
||||||
|
strOutputFile = strOutputFile.replaceAll("\\\\", "/");
|
||||||
|
|
||||||
|
FileSeekableStream fileSeekStream = null;
|
||||||
|
try {
|
||||||
|
JPEGEncodeParam jpegEncodeParam = new JPEGEncodeParam();
|
||||||
|
|
||||||
|
TIFFEncodeParam tiffEncodeParam = new TIFFEncodeParam();
|
||||||
|
tiffEncodeParam.setCompression(TIFFEncodeParam.COMPRESSION_GROUP4);
|
||||||
|
tiffEncodeParam.setLittleEndian(false);
|
||||||
|
|
||||||
|
String strFilePrefix = strInputFile.substring(strInputFile.lastIndexOf("/") + 1, strInputFile.lastIndexOf("."));
|
||||||
|
|
||||||
|
fileSeekStream = new FileSeekableStream(strInputFile);
|
||||||
|
ImageDecoder imageDecoder = ImageCodec.createImageDecoder("TIFF", fileSeekStream, null);
|
||||||
|
int intTifCount = imageDecoder.getNumPages();
|
||||||
|
logger.info("该tif文件共有【" + intTifCount + "】页");
|
||||||
|
|
||||||
|
String strJpgPath;
|
||||||
|
String strJpgUrl;
|
||||||
|
if (intTifCount == 1) {
|
||||||
|
// 如果是单页tif文件,则转换的目标文件夹就在指定的位置
|
||||||
|
strJpgPath = strOutputFile.substring(0, strOutputFile.lastIndexOf("/"));
|
||||||
|
} else {
|
||||||
|
// 如果是多页tif文件,则在目标文件夹下,按照文件名再创建子目录,将转换后的文件放入此新建的子目录中
|
||||||
|
strJpgPath = strOutputFile.substring(0, strOutputFile.lastIndexOf("."));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理目标文件夹,如果不存在则自动创建
|
||||||
|
File fileJpgPath = new File(strJpgPath);
|
||||||
|
if (!fileJpgPath.exists() && !fileJpgPath.mkdirs()) {
|
||||||
|
logger.error("{} 创建失败", strJpgPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 循环,处理每页tif文件,转换为jpg
|
||||||
|
for (int i = 0; i < intTifCount; i++) {
|
||||||
|
String strJpg;
|
||||||
|
if (intTifCount == 1) {
|
||||||
|
strJpg = strJpgPath + "/" + strFilePrefix + ".jpg";
|
||||||
|
strJpgUrl = strFilePrefix + ".jpg";
|
||||||
|
} else {
|
||||||
|
strJpg = strJpgPath + "/" + i + ".jpg";
|
||||||
|
strJpgUrl = strFilePrefix + "/" + i + ".jpg";
|
||||||
|
}
|
||||||
|
|
||||||
|
File fileJpg = new File(strJpg);
|
||||||
|
|
||||||
|
// 如果文件不存在,则生成
|
||||||
|
if (!fileJpg.exists()) {
|
||||||
|
RenderedImage renderedImage = imageDecoder.decodeAsRenderedImage(i);
|
||||||
|
ParameterBlock pb = new ParameterBlock();
|
||||||
|
pb.addSource(renderedImage);
|
||||||
|
pb.add(fileJpg.toString());
|
||||||
|
pb.add("JPEG");
|
||||||
|
pb.add(jpegEncodeParam);
|
||||||
|
|
||||||
|
RenderedOp renderedOp = JAI.create("filestore", pb);
|
||||||
|
renderedOp.dispose();
|
||||||
|
|
||||||
|
logger.info("每页分别保存至: " + fileJpg.getCanonicalPath());
|
||||||
|
} else {
|
||||||
|
logger.info("JPG文件已存在: " + fileJpg.getCanonicalPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
listImageFiles.add(strJpgUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
return listImageFiles;
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
if (fileSeekStream != null) {
|
||||||
|
try {
|
||||||
|
fileSeekStream.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将Jpg图片转换为Pdf文件
|
||||||
|
*
|
||||||
|
* @param strJpgFile 输入的jpg的路径和文件名
|
||||||
|
* @param strPdfFile 输出的pdf的路径和文件名
|
||||||
|
*/
|
||||||
|
public static void convertJpg2Pdf(String strJpgFile, String strPdfFile) {
|
||||||
|
Document document = new Document();
|
||||||
|
// 设置文档页边距
|
||||||
|
document.setMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
FileOutputStream fos = null;
|
||||||
|
try {
|
||||||
|
fos = new FileOutputStream(strPdfFile);
|
||||||
|
PdfWriter.getInstance(document, fos);
|
||||||
|
// 打开文档
|
||||||
|
document.open();
|
||||||
|
// 获取图片的宽高
|
||||||
|
Image image = Image.getInstance(strJpgFile);
|
||||||
|
float floatImageHeight = image.getScaledHeight();
|
||||||
|
float floatImageWidth = image.getScaledWidth();
|
||||||
|
// 设置页面宽高与图片一致
|
||||||
|
Rectangle rectangle = new Rectangle(floatImageWidth, floatImageHeight);
|
||||||
|
document.setPageSize(rectangle);
|
||||||
|
// 图片居中
|
||||||
|
image.setAlignment(Image.ALIGN_CENTER);
|
||||||
|
//新建一页添加图片
|
||||||
|
document.newPage();
|
||||||
|
document.add(image);
|
||||||
|
} catch (Exception ioe) {
|
||||||
|
ioe.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
//关闭文档
|
||||||
|
document.close();
|
||||||
|
try {
|
||||||
|
assert fos != null;
|
||||||
|
fos.flush();
|
||||||
|
fos.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将Tif图片转换为Pdf文件(支持多页Tif)
|
||||||
|
*
|
||||||
|
* @param strTifFile 输入的tif的路径和文件名
|
||||||
|
* @param strPdfFile 输出的pdf的路径和文件名
|
||||||
|
* @return File
|
||||||
|
*/
|
||||||
|
public static File convertTif2Pdf(String strTifFile, String strPdfFile) {
|
||||||
|
try {
|
||||||
|
RandomAccessFileOrArray rafa = new RandomAccessFileOrArray(strTifFile);
|
||||||
|
|
||||||
|
Document document = new Document();
|
||||||
|
// 设置文档页边距
|
||||||
|
document.setMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
PdfWriter.getInstance(document, new FileOutputStream(strPdfFile));
|
||||||
|
document.open();
|
||||||
|
int intPages = TiffImage.getNumberOfPages(rafa);
|
||||||
|
Image image;
|
||||||
|
File filePDF;
|
||||||
|
|
||||||
|
if (intPages == 1) {
|
||||||
|
String strJpg = strTifFile.substring(0, strTifFile.lastIndexOf(".")) + ".jpg";
|
||||||
|
File fileJpg = new File(strJpg);
|
||||||
|
List<String> listPic2Jpg = convertTif2Jpg(strTifFile, strJpg);
|
||||||
|
|
||||||
|
if (listPic2Jpg != null && fileJpg.exists()) {
|
||||||
|
convertJpg2Pdf(strJpg, strPdfFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
for (int i = 1; i <= intPages; i++) {
|
||||||
|
image = TiffImage.getTiffImage(rafa, i);
|
||||||
|
// 设置页面宽高与图片一致
|
||||||
|
Rectangle pageSize = new Rectangle(image.getScaledWidth(), image.getScaledHeight());
|
||||||
|
document.setPageSize(pageSize);
|
||||||
|
// 图片居中
|
||||||
|
image.setAlignment(Image.ALIGN_CENTER);
|
||||||
|
//新建一页添加图片
|
||||||
|
document.newPage();
|
||||||
|
document.add(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
rafa.close();
|
||||||
|
|
||||||
|
filePDF = new File(strPdfFile);
|
||||||
|
|
||||||
|
return filePDF;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -32,22 +32,24 @@ public class DownloadUtils {
|
|||||||
* @return 本地文件绝对路径
|
* @return 本地文件绝对路径
|
||||||
*/
|
*/
|
||||||
public static ReturnResponse<String> downLoad(FileAttribute fileAttribute, String fileName) {
|
public static ReturnResponse<String> downLoad(FileAttribute fileAttribute, String fileName) {
|
||||||
String urlStr = fileAttribute.getUrl();
|
String urlStr = fileAttribute.getUrl().replaceAll("\\+", "%20");
|
||||||
ReturnResponse<String> response = new ReturnResponse<>(0, "下载成功!!!", "");
|
ReturnResponse<String> response = new ReturnResponse<>(0, "下载成功!!!", "");
|
||||||
String realPath = DownloadUtils.getRelFilePath(fileName, fileAttribute);
|
String realPath = DownloadUtils.getRelFilePath(fileName, fileAttribute);
|
||||||
try {
|
try {
|
||||||
URL url = WebUtils.normalizedURL(urlStr);
|
URL url = WebUtils.normalizedURL(urlStr);
|
||||||
if (isHttpUrl(url)) {
|
if (!fileAttribute.getSkipDownLoad()) {
|
||||||
File realFile = new File(realPath);
|
if (isHttpUrl(url)) {
|
||||||
FileUtils.copyURLToFile(url,realFile);
|
File realFile = new File(realPath);
|
||||||
} else if (isFtpUrl(url)) {
|
FileUtils.copyURLToFile(url, realFile);
|
||||||
String ftpUsername = WebUtils.getUrlParameterReg(fileAttribute.getUrl(), URL_PARAM_FTP_USERNAME);
|
} else if (isFtpUrl(url)) {
|
||||||
String ftpPassword = WebUtils.getUrlParameterReg(fileAttribute.getUrl(), URL_PARAM_FTP_PASSWORD);
|
String ftpUsername = WebUtils.getUrlParameterReg(fileAttribute.getUrl(), URL_PARAM_FTP_USERNAME);
|
||||||
String ftpControlEncoding = WebUtils.getUrlParameterReg(fileAttribute.getUrl(), URL_PARAM_FTP_CONTROL_ENCODING);
|
String ftpPassword = WebUtils.getUrlParameterReg(fileAttribute.getUrl(), URL_PARAM_FTP_PASSWORD);
|
||||||
FtpUtils.download(fileAttribute.getUrl(), realPath, ftpUsername, ftpPassword, ftpControlEncoding);
|
String ftpControlEncoding = WebUtils.getUrlParameterReg(fileAttribute.getUrl(), URL_PARAM_FTP_CONTROL_ENCODING);
|
||||||
} else {
|
FtpUtils.download(fileAttribute.getUrl(), realPath, ftpUsername, ftpPassword, ftpControlEncoding);
|
||||||
response.setCode(1);
|
} else {
|
||||||
response.setMsg("url不能识别url" + urlStr);
|
response.setCode(1);
|
||||||
|
response.setMsg("url不能识别url" + urlStr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
response.setContent(realPath);
|
response.setContent(realPath);
|
||||||
response.setMsg(fileName);
|
response.setMsg(fileName);
|
||||||
@@ -85,6 +87,13 @@ public class DownloadUtils {
|
|||||||
if (!dirFile.exists() && !dirFile.mkdirs()) {
|
if (!dirFile.exists() && !dirFile.mkdirs()) {
|
||||||
logger.error("创建目录【{}】失败,可能是权限不够,请检查", fileDir);
|
logger.error("创建目录【{}】失败,可能是权限不够,请检查", fileDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 文件已在本地存在,跳过文件下载
|
||||||
|
File realFile = new File(realPath);
|
||||||
|
if (realFile.exists()) {
|
||||||
|
fileAttribute.setSkipDownLoad(true);
|
||||||
|
}
|
||||||
|
|
||||||
return realPath;
|
return realPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -402,7 +402,7 @@ class BytesEncodingDetect extends Encoding {
|
|||||||
int row, column;
|
int row, column;
|
||||||
rawtextlen = rawtext.length;
|
rawtextlen = rawtext.length;
|
||||||
for (i = 0; i < rawtextlen; i++) {
|
for (i = 0; i < rawtextlen; i++) {
|
||||||
if (rawtext[i] == '~') {
|
if (rawtext[i] == '~' && i < rawtextlen - 1) {
|
||||||
if (rawtext[i + 1] == '{') {
|
if (rawtext[i + 1] == '{') {
|
||||||
hzstart++;
|
hzstart++;
|
||||||
i += 2;
|
i += 2;
|
||||||
@@ -4641,4 +4641,4 @@ class Encoding {
|
|||||||
nicename[OTHER] = "OTHER";
|
nicename[OTHER] = "OTHER";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
28
server/src/main/java/cn/keking/utils/FileHeaderRar.java
Normal file
28
server/src/main/java/cn/keking/utils/FileHeaderRar.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package cn.keking.utils;
|
||||||
|
|
||||||
|
public class FileHeaderRar {
|
||||||
|
|
||||||
|
private String fileNameW;
|
||||||
|
private Boolean isDirectory;
|
||||||
|
|
||||||
|
public FileHeaderRar(String fileNameW, Boolean isDirectory) {
|
||||||
|
this.fileNameW = fileNameW;
|
||||||
|
this.isDirectory = isDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileNameW() {
|
||||||
|
return fileNameW;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileNameW(String fileNameW) {
|
||||||
|
this.fileNameW = fileNameW;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getDirectory() {
|
||||||
|
return isDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDirectory(Boolean directory) {
|
||||||
|
isDirectory = directory;
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user