opt
This commit is contained in:
parent
e98486c4f8
commit
59d1a9de3a
@ -3,7 +3,6 @@ package com.knowledge.base.infrastructure.north.controller;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.knowledge.base.application.service.DocAppService;
|
||||
import com.knowledge.base.application.service.UserAppService;
|
||||
import com.knowledge.base.domain.common.enums.DocMetaPropEnum;
|
||||
@ -182,7 +181,8 @@ public class FileWriteController {
|
||||
String[] supportedSuffix = dynamicConfig.getSupportedSearchFileSuffix().split(",");
|
||||
Set<String> supportedTypes = Arrays.stream(supportedSuffix).map(String::trim).collect(Collectors.toSet());
|
||||
boolean allowSaveToLocal = searchable && supportedTypes.contains(suffix);
|
||||
String localRelaFilePath = String.format("%s/%s", dateFolder, originFileNameWithSuffix);
|
||||
String localRelaDir = buildLocalRelaDir(dateFolder, uploader);
|
||||
String localRelaFilePath = buildLocalRelaFilePath(localRelaDir, originFileNameWithSuffix);
|
||||
|
||||
boolean isPublic = Optional.ofNullable(objectStorageProperties.getPublicBuckets())
|
||||
.map(buckets -> buckets.contains(bucket))
|
||||
@ -206,7 +206,7 @@ public class FileWriteController {
|
||||
// 允许保存到本地
|
||||
if (allowSaveToLocal) {
|
||||
String excludePrefix = objectStorageProperties.getLocalSearchablePathPrefix();
|
||||
String localDir = Paths.get(excludePrefix, dateFolder).toString();
|
||||
String localDir = Paths.get(excludePrefix, localRelaDir).toString();
|
||||
File localTargetDir = new File(localDir);
|
||||
if (!localTargetDir.exists()) {
|
||||
localTargetDir.mkdirs();
|
||||
@ -230,5 +230,24 @@ public class FileWriteController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造本地文件路径(不包含文件名本身)
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
private static String buildLocalRelaDir(String... params) {
|
||||
return Arrays.stream(params).filter(StrUtil::isNotBlank).collect(Collectors.joining("/"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造本地文件路径(带文件名)
|
||||
* @param relaDir
|
||||
* @param originFileNameWithSuffix
|
||||
* @return
|
||||
*/
|
||||
private static String buildLocalRelaFilePath(String relaDir, String originFileNameWithSuffix) {
|
||||
return String.format("%s/%s", relaDir, originFileNameWithSuffix);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user