Commit 3a52fc54 authored by alex yao's avatar alex yao

FIX:计算文件大小

parent 7da2bd5d
...@@ -85,9 +85,9 @@ public class KnowledgeServiceImpl implements KnowledgeService { ...@@ -85,9 +85,9 @@ public class KnowledgeServiceImpl implements KnowledgeService {
String documentName = documentFile.getOriginalFilename(); String documentName = documentFile.getOriginalFilename();
String type = documentFile.getOriginalFilename().substring(documentFile.getOriginalFilename().lastIndexOf(".") + 1, documentFile.getOriginalFilename().length()); String type = documentFile.getOriginalFilename().substring(documentFile.getOriginalFilename().lastIndexOf(".") + 1, documentFile.getOriginalFilename().length());
File file = File.createTempFile(UUIDTool.getUUID(), "." + type); File file = File.createTempFile(UUIDTool.getUUID(), "." + type);
documentFile.transferTo(file);
// 文件大小 // 文件大小
long fileSizeInBytes = file.length(); long fileSizeInBytes = file.length();
documentFile.transferTo(file);
// 统计文件字符数 // 统计文件字符数
String fileContent = DocumentLoad.documentToText(file).replaceAll(StringUtils.LF, StringUtils.EMPTY).replaceAll(StringUtils.CR, StringUtils.EMPTY);//文件内容 String fileContent = DocumentLoad.documentToText(file).replaceAll(StringUtils.LF, StringUtils.EMPTY).replaceAll(StringUtils.CR, StringUtils.EMPTY);//文件内容
long charCount = fileContent.length(); long charCount = fileContent.length();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment