Compare commits

..

4 Commits

Author SHA1 Message Date
a3485dd9b7 Merge pull request #230 from gitchenjh/master
3.5.1版
2021-04-06 17:47:07 +08:00
5a28b89f46 3.5.1版 2021-04-06 16:45:18 +08:00
58b1b50c2e 修复:pdf.js 跨域问题 2021-04-06 16:44:40 +08:00
kl
8f75df15e2 修复 tif、tiff 文件预览初始内存太小预览失败的问题 2021-03-26 10:05:58 +08:00
12 changed files with 32 additions and 16 deletions

View File

@ -28,5 +28,5 @@ 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-3.5/bin
ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider","-Dspring.config.location=/opt/kkFileView-3.5/config/application.properties","-jar","/opt/kkFileView-3.5/bin/kkFileView-3.5.jar"]
ENV KKFILEVIEW_BIN_FOLDER /opt/kkFileView-3.5.1/bin
ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider","-Dspring.config.location=/opt/kkFileView-3.5.1/config/application.properties","-jar","/opt/kkFileView-3.5.1/bin/kkFileView-3.5.1.jar"]

View File

@ -7,7 +7,7 @@
<parent>
<artifactId>filepreview</artifactId>
<groupId>cn.keking</groupId>
<version>3.5</version>
<version>3.5.1</version>
</parent>
<artifactId>office-plugin</artifactId>

View File

@ -6,7 +6,7 @@
<groupId>cn.keking</groupId>
<artifactId>filepreview</artifactId>
<version>3.5</version>
<version>3.5.1</version>
<properties>
<java.version>1.8</java.version>

View File

@ -6,7 +6,7 @@
<parent>
<artifactId>filepreview</artifactId>
<groupId>cn.keking</groupId>
<version>3.5</version>
<version>3.5.1</version>
</parent>
<artifactId>kkFileView</artifactId>
@ -149,7 +149,7 @@
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.16</version>
<version>1.4.15</version>
</dependency>
<dependency>
<groupId>com.googlecode.concurrentlinkedhashmap</groupId>

View File

@ -6,4 +6,4 @@ echo Starting kkFileView...
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 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-3.5.jar -> ..\log\kkFileView.log
java -Dspring.config.location=..\config\application.properties -jar kkFileView-3.5.1.jar -> ..\log\kkFileView.log

View File

@ -29,4 +29,4 @@ 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-3.5.jar > ../log/kkFileView.log 2>&1 &
nohup java -Dfile.encoding=UTF-8 -Dspring.config.location=../config/application.properties -jar kkFileView-3.5.1.jar > ../log/kkFileView.log 2>&1 &

View File

@ -1,5 +1,6 @@
[#ftl]
[#-- @implicitly included --]
[#-- @ftlvariable name="initializeMemorySize" type="java.lang.Number" --]
[#-- @ftlvariable name="currentUrl" type="java.lang.String" --]
[#-- @ftlvariable name="file" type="cn.keking.model.FileAttribute" --]
[#-- @ftlvariable name="fileName" type="java.lang.String" --]

View File

@ -2,8 +2,10 @@ package cn.keking.service.impl;
import cn.keking.model.FileAttribute;
import cn.keking.service.FilePreview;
import cn.keking.utils.WebUtils;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
/**
* tiff 图片文件处理
@ -14,6 +16,9 @@ import org.springframework.ui.Model;
public class TiffFilePreviewImpl implements FilePreview {
private final PictureFilePreviewImpl pictureFilePreview;
private static final String INITIALIZE_MEMORY_SIZE = "initializeMemorySize";
//默认初始化 50MB 内存
private static final long INITIALIZE_MEMORY_SIZE_VALUE_DEFAULT = 1024L * 1024 * 50;
public TiffFilePreviewImpl(PictureFilePreviewImpl pictureFilePreview) {
this.pictureFilePreview = pictureFilePreview;
@ -22,6 +27,12 @@ public class TiffFilePreviewImpl implements FilePreview {
@Override
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
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;
}
}

View File

@ -30,8 +30,6 @@ public class FilterConfiguration {
Set<String> filterUri = new HashSet<>();
filterUri.add("/onlinePreview");
filterUri.add("/picturesPreview");
filterUri.add("/getCorsFile");
filterUri.add("/addTask");
TrustHostFilter filter = new TrustHostFilter();
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
registrationBean.setFilter(filter);

View File

@ -2019,7 +2019,7 @@ var validateFileURL;
{
var HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
validateFileURL = function validateFileURL(file, base) {
validateFileURL = function validateFileURL(file) {
if (file === undefined) {
return;
}
@ -2036,7 +2036,7 @@ var validateFileURL;
protocol = _ref11.protocol;
if (origin !== viewerOrigin && protocol !== "blob:") {
return (base.endsWith('/') ? base : base + '/') + 'getCorsFile?urlPath=' + encodeURIComponent(file);
throw new Error("file origin does not match viewer's");
}
} catch (ex) {
var message = ex && ex.message;
@ -2089,14 +2089,12 @@ function loadAndEnablePDFBug(enabledTabs) {
function webViewerInitialized() {
var appConfig = PDFViewerApplication.appConfig;
var file;
var base;
var disableDownload;
var queryString = document.location.search.substring(1);
var params = (0, _ui_utils.parseQueryString)(queryString);
file = "file" in params ? params.file : _app_options.AppOptions.get("defaultUrl");
base = 'base' in params ? params.base : appConfig.defaultUrl;
disableDownload = 'disabledownload' in params ? params.disabledownload : 'false';
validateFileURL(file, base);
validateFileURL(file);
var fileInput = document.createElement("input");
fileInput.id = appConfig.openFileInputName;
fileInput.className = "fileInput";

View File

@ -21,7 +21,12 @@
</#if>
</body>
<script type="text/javascript">
document.getElementsByTagName('iframe')[0].src = "${baseUrl}pdfjs/web/viewer.html?base=${baseUrl}&file=" + encodeURIComponent('${finalUrl}') + "&disabledownload=${pdfDownloadDisable}";
var url = '${finalUrl}';
var baseUrl = '${baseUrl}'.endsWith('/') ? '${baseUrl}' : '${baseUrl}' + '/';
if (!url.startsWith(baseUrl)) {
url = baseUrl + 'getCorsFile?urlPath=' + encodeURIComponent(url);
}
document.getElementsByTagName('iframe')[0].src = "${baseUrl}pdfjs/web/viewer.html?file=" + encodeURIComponent(url) + "&disabledownload=${pdfDownloadDisable}";
document.getElementsByTagName('iframe')[0].height = document.documentElement.clientHeight - 10;
/**
* 页面变化调整高度

View File

@ -30,6 +30,9 @@
var xhr = new XMLHttpRequest();
xhr.responseType = 'arraybuffer';
xhr.open('GET', $("#currentUrl").val());
var config = {};
config.TOTAL_MEMORY = ${initializeMemorySize};
Tiff.initialize(config)
xhr.onload = function (e) {
var tiff = new Tiff({buffer: xhr.response});
var canvas = tiff.toCanvas();