parent
778676c8da
commit
91d395dc71
|
@ -33,17 +33,6 @@ public class FileUtils {
|
||||||
public static final String ATTACHMENT_TMP_DIR = "/opt/metersphere/data/attachment/tmp";
|
public static final String ATTACHMENT_TMP_DIR = "/opt/metersphere/data/attachment/tmp";
|
||||||
|
|
||||||
public static void validateFileName(String fileName) {
|
public static void validateFileName(String fileName) {
|
||||||
if (StringUtils.isNotEmpty(fileName) && StringUtils.contains(fileName, File.separator)) {
|
|
||||||
MSException.throwException(Translator.get("invalid_parameter"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上传Minio的文件名称检查只需要判断是否带有./ ../ 这样的非法文件名
|
|
||||||
*
|
|
||||||
* @param fileName
|
|
||||||
*/
|
|
||||||
public static void validateMinIOFileName(String fileName) {
|
|
||||||
if (StringUtils.isNotEmpty(fileName) && StringUtils.contains(fileName, "." + File.separator)) {
|
if (StringUtils.isNotEmpty(fileName) && StringUtils.contains(fileName, "." + File.separator)) {
|
||||||
MSException.throwException(Translator.get("invalid_parameter"));
|
MSException.throwException(Translator.get("invalid_parameter"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class MinIOFileRepository implements FileRepository {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String saveFile(MultipartFile file, FileRequest request) throws Exception {
|
public String saveFile(MultipartFile file, FileRequest request) throws Exception {
|
||||||
FileUtils.validateMinIOFileName(request.getFileName());
|
FileUtils.validateFileName(request.getFileName());
|
||||||
String bucket = minioProperties.getBucket();
|
String bucket = minioProperties.getBucket();
|
||||||
String fileName = request.getProjectId() + "/" + request.getFileName();
|
String fileName = request.getProjectId() + "/" + request.getFileName();
|
||||||
minioClient.putObject(PutObjectArgs.builder()
|
minioClient.putObject(PutObjectArgs.builder()
|
||||||
|
|
Loading…
Reference in New Issue