fix(项目管理): 修复git文件无法pull的问题,同时在获取文件方法上增加校验判断
--bug=1023211 --user=宋天阳 【项目管理】文件管理 - git文件详情 - 关联用例,pull文件失败 https://www.tapd.cn/55049933/s/1336948
This commit is contained in:
parent
0ea040f129
commit
d7eaff9b44
|
@ -34,11 +34,15 @@ public class FileUtils {
|
||||||
public static final String ATTACHMENT_DIR = "/opt/metersphere/data/attachment";
|
public static final String ATTACHMENT_DIR = "/opt/metersphere/data/attachment";
|
||||||
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... fileNames) {
|
||||||
|
if (fileNames != null) {
|
||||||
|
for (String fileName : fileNames) {
|
||||||
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"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static byte[] listBytesToZip(Map<String, byte[]> mapReport) {
|
public static byte[] listBytesToZip(Map<String, byte[]> mapReport) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import io.metersphere.commons.utils.FileUtils;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
import io.metersphere.request.MdUploadRequest;
|
import io.metersphere.request.MdUploadRequest;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.core.io.FileSystemResource;
|
import org.springframework.core.io.FileSystemResource;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
@ -14,7 +15,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
|
@ -43,10 +43,8 @@ public class ResourceService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<FileSystemResource> getUiResultImage(String name, String reportId) {
|
public ResponseEntity<FileSystemResource> getUiResultImage(String name, String reportId) {
|
||||||
if (name.contains("/")) {
|
FileUtils.validateFileName(name, reportId);
|
||||||
MSException.throwException(Translator.get("invalid_parameter"));
|
return getImage(FileUtils.UI_IMAGE_DIR + File.separator + reportId + File.separator + name);
|
||||||
}
|
|
||||||
return getImage(FileUtils.UI_IMAGE_DIR + "/" + reportId + "/" + name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<FileSystemResource> getImage(String path) {
|
public ResponseEntity<FileSystemResource> getImage(String path) {
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class ApiRelateService {
|
||||||
if (CollectionUtils.isNotEmpty(requestList)) {
|
if (CollectionUtils.isNotEmpty(requestList)) {
|
||||||
try {
|
try {
|
||||||
microService.postForData(MicroServiceName.API_TEST,
|
microService.postForData(MicroServiceName.API_TEST,
|
||||||
"/api/definition/update/file/",
|
"/api/definition/update/file",
|
||||||
requestList);
|
requestList);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e);
|
LogUtil.error(e);
|
||||||
|
|
Loading…
Reference in New Issue