Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
K
know-base
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
张京坤
know-base
Commits
bcd49ed5
提交
bcd49ed5
authored
1月 22, 2024
作者:
ZhangJingKun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
编辑最大文件现在
上级
b32d537c
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
6 行增加
和
4 行删除
+6
-4
DocumentServiceImpl.java
...a/com/zzsn/knowbase/service/impl/DocumentServiceImpl.java
+4
-4
LocalFileServiceImpl.java
.../com/zzsn/knowbase/service/impl/LocalFileServiceImpl.java
+2
-0
没有找到文件。
src/main/java/com/zzsn/knowbase/service/impl/DocumentServiceImpl.java
浏览文件 @
bcd49ed5
...
@@ -45,8 +45,8 @@ public class DocumentServiceImpl implements DocumentService {
...
@@ -45,8 +45,8 @@ public class DocumentServiceImpl implements DocumentService {
/**
/**
* 大小限制,默认10M
* 大小限制,默认10M
*/
*/
@Value
(
"${
document.file-size.limit:10485760
}"
)
@Value
(
"${
filesize-max
}"
)
private
Long
docFileSizeLimit
;
private
String
filesizeMax
;
@Value
(
"${files.docservice.url.site}"
)
@Value
(
"${files.docservice.url.site}"
)
private
String
documentServerHost
;
private
String
documentServerHost
;
@Value
(
"${files.docservice.url.api}"
)
@Value
(
"${files.docservice.url.api}"
)
...
@@ -293,8 +293,8 @@ public class DocumentServiceImpl implements DocumentService {
...
@@ -293,8 +293,8 @@ public class DocumentServiceImpl implements DocumentService {
log
.
error
(
"$$$ 目标文档[{}]不可读,无法打开!"
,
docFile
.
getAbsolutePath
());
log
.
error
(
"$$$ 目标文档[{}]不可读,无法打开!"
,
docFile
.
getAbsolutePath
());
throw
new
DocumentException
(
ErrorCodeEnum
.
DOC_FILE_UNREADABLE
);
throw
new
DocumentException
(
ErrorCodeEnum
.
DOC_FILE_UNREADABLE
);
}
}
if
(
docFile
.
length
()
>
docFileSizeLimit
)
{
if
(
docFile
.
length
()
>
Long
.
parseLong
(
filesizeMax
)
)
{
log
.
error
(
"$$$ 目标文档大小超过限制({}B > {}B),无法打开!"
,
docFile
.
length
(),
docFileSizeLimit
);
log
.
error
(
"$$$ 目标文档大小超过限制({}B > {}B),无法打开!"
,
docFile
.
length
(),
Long
.
parseLong
(
filesizeMax
)
);
throw
new
DocumentException
(
ErrorCodeEnum
.
DOC_FILE_OVERSIZE
);
throw
new
DocumentException
(
ErrorCodeEnum
.
DOC_FILE_OVERSIZE
);
}
}
String
ext
=
StringUtils
.
lowerCase
(
FilenameUtils
.
getExtension
(
docFile
.
getName
()));
String
ext
=
StringUtils
.
lowerCase
(
FilenameUtils
.
getExtension
(
docFile
.
getName
()));
...
...
src/main/java/com/zzsn/knowbase/service/impl/LocalFileServiceImpl.java
浏览文件 @
bcd49ed5
...
@@ -80,6 +80,7 @@ public class LocalFileServiceImpl implements ILocalFileService {
...
@@ -80,6 +80,7 @@ public class LocalFileServiceImpl implements ILocalFileService {
String
fileExtension
=
fileUtility
.
getFileExtension
(
fileName
);
// 获取文件扩展名
String
fileExtension
=
fileUtility
.
getFileExtension
(
fileName
);
// 获取文件扩展名
String
fileType
=
fileUtility
.
getFileType
(
fileName
);
//获取文件类型
String
fileType
=
fileUtility
.
getFileType
(
fileName
);
//获取文件类型
long
fileSize
=
file
.
getSize
();
// get file size
long
fileSize
=
file
.
getSize
();
// get file size
log
.
info
(
"文件上传:"
+
fileName
);
// check if the file size exceeds the maximum file size or is less than 0
// check if the file size exceeds the maximum file size or is less than 0
if
(
fileUtility
.
getMaxFileSize
()
<
fileSize
||
fileSize
<=
0
)
{
if
(
fileUtility
.
getMaxFileSize
()
<
fileSize
||
fileSize
<=
0
)
{
...
@@ -107,6 +108,7 @@ public class LocalFileServiceImpl implements ILocalFileService {
...
@@ -107,6 +108,7 @@ public class LocalFileServiceImpl implements ILocalFileService {
knowFile
.
setFileType
(
fileType
);
knowFile
.
setFileType
(
fileType
);
knowFile
.
setFileSize
(
fileSize
);
knowFile
.
setFileSize
(
fileSize
);
Result
result
=
Result
.
OK
(
knowFile
);
Result
result
=
Result
.
OK
(
knowFile
);
log
.
info
(
"文件上传成功:"
+
fileName
+
"---"
+
filePath
);
return
result
;
// create user metadata and return it
return
result
;
// create user metadata and return it
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论