mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-04-29 11:36:45 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e8bf0d359 | ||
|
|
986f562266 |
@@ -201,6 +201,12 @@
|
||||
<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>
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.keking.config.ConfigConstants;
|
||||
import cn.keking.model.FileAttribute;
|
||||
import cn.keking.model.FileType;
|
||||
import cn.keking.model.ReturnResponse;
|
||||
import io.mola.galimatias.GalimatiasParseException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -81,7 +82,6 @@ public class DownloadUtils {
|
||||
public static byte[] getBytesFromUrl(String urlStr) throws IOException {
|
||||
InputStream is = getInputStreamFromUrl(urlStr);
|
||||
if (is == null) {
|
||||
// urlStr = URLUtil.normalize(urlStr, true, true);
|
||||
is = getInputStreamFromUrl(urlStr);
|
||||
if (is == null) {
|
||||
logger.error("文件下载异常:url:{}", urlStr);
|
||||
@@ -98,13 +98,14 @@ public class DownloadUtils {
|
||||
|
||||
private static InputStream getInputStreamFromUrl(String urlStr) {
|
||||
try {
|
||||
URL url = new URL(urlStr);
|
||||
|
||||
URL url = io.mola.galimatias.URL.parse(urlStr).toJavaURL();
|
||||
URLConnection connection = url.openConnection();
|
||||
if (connection instanceof HttpURLConnection) {
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
|
||||
}
|
||||
return connection.getInputStream();
|
||||
} catch (IOException e) {
|
||||
} catch (IOException | GalimatiasParseException e) {
|
||||
logger.warn("连接url异常:url:{}", urlStr);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -19,18 +19,17 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="panel-group container" id="accordion">
|
||||
<h1>文件预览项目接入和测试界面</h1>
|
||||
<div class="panel-group" id="accordion">
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion"
|
||||
href="#collapseOne">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
|
||||
接入说明
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="collapseOne" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<div>
|
||||
如果你的项目需要接入文件预览项目,达到对docx、excel、ppt、jpg等文件的预览效果,那么通过在你的项目中加入下面的代码就可以
|
||||
@@ -49,7 +48,6 @@ window.open('http://127.0.0.1:8012/picturesPreview?urls='+encodeURIComponent(bas
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
@@ -59,12 +57,11 @@ window.open('http://127.0.0.1:8012/picturesPreview?urls='+encodeURIComponent(bas
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="collapseTwo" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<div style="padding: 10px">
|
||||
<form enctype="multipart/form-data" id="fileUpload">
|
||||
<input type="file" name="file"/>
|
||||
<input type="button" id="btnsubmit" value=" 上 传 " />
|
||||
<input type="button" id="btnubmit" value=" 上 传 "/>
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
@@ -72,21 +69,18 @@ window.open('http://127.0.0.1:8012/picturesPreview?urls='+encodeURIComponent(bas
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion"
|
||||
href="#collapseThree">
|
||||
更新记录
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapseThree">
|
||||
发版记录
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="collapseThree" class="panel-collapse collapse in">
|
||||
<div class="panel-body">
|
||||
<div>
|
||||
2020年12月27日 :<br>
|
||||
2020年年终大版本更新,架构全面设计,代码全面重构,代码质量全面提升,二次开发更便捷,欢迎拉源码品鉴,提issue、pr共同建设
|
||||
2020年年终大版本更新,架构全面设计,代码全面重构,代码质量全面提升,二次开发更便捷,欢迎拉源码品鉴,提issue、pr共同建设<br>
|
||||
1. 架构模块调整,大量的代码重构,代码质量提升N个等级,欢迎品鉴<br>
|
||||
2. 增强XML文件预览效果,新增XML文档数结构预览<br>
|
||||
3. 新增markdown文件预览支持,预览支持md渲染和源文本切换支持<br>
|
||||
@@ -154,7 +148,7 @@ window.open('http://127.0.0.1:8012/picturesPreview?urls='+encodeURIComponent(bas
|
||||
2.项目github开源:<a href="https://github.com/kekingcn/kkFileView" target="_blank">https://github.com/kekingcn/kkFileView</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div id="comments"></div>
|
||||
</div>
|
||||
@@ -190,7 +184,7 @@ window.open('http://127.0.0.1:8012/picturesPreview?urls='+encodeURIComponent(bas
|
||||
url: '${baseUrl}deleteFile?fileName=' + encodeURIComponent(fileName),
|
||||
success: function (data) {
|
||||
// 删除完成,刷新table
|
||||
if (1 == data.code) {
|
||||
if (1 === data.code) {
|
||||
alert(data.msg);
|
||||
} else {
|
||||
$('#table').bootstrapTable('refresh', {});
|
||||
@@ -201,6 +195,7 @@ window.open('http://127.0.0.1:8012/picturesPreview?urls='+encodeURIComponent(bas
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$('#table').bootstrapTable({
|
||||
url: 'listFiles',
|
||||
@@ -228,12 +223,12 @@ window.open('http://127.0.0.1:8012/picturesPreview?urls='+encodeURIComponent(bas
|
||||
$(".loading_container").css("height", height).show();
|
||||
}
|
||||
|
||||
$("#btnsubmit").click(function () {
|
||||
$("#btnSubmit").click(function () {
|
||||
showLoadingDiv();
|
||||
$("#fileUpload").ajaxSubmit({
|
||||
success: function (data) {
|
||||
// 上传完成,刷新table
|
||||
if (1 == data.code) {
|
||||
if (1 === data.code) {
|
||||
alert(data.msg);
|
||||
} else {
|
||||
$('#table').bootstrapTable('refresh', {});
|
||||
|
||||
Reference in New Issue
Block a user