diff --git a/backend/src/main/java/io/metersphere/controller/request/MdUploadRequest.java b/backend/src/main/java/io/metersphere/controller/request/MdUploadRequest.java index de2609fdcd..d91500bbb1 100644 --- a/backend/src/main/java/io/metersphere/controller/request/MdUploadRequest.java +++ b/backend/src/main/java/io/metersphere/controller/request/MdUploadRequest.java @@ -7,4 +7,5 @@ import lombok.Setter; @Setter public class MdUploadRequest { private String id; + private String fileName; } diff --git a/backend/src/main/java/io/metersphere/service/ResourceService.java b/backend/src/main/java/io/metersphere/service/ResourceService.java index 5bd34eb452..ebe96360dd 100644 --- a/backend/src/main/java/io/metersphere/service/ResourceService.java +++ b/backend/src/main/java/io/metersphere/service/ResourceService.java @@ -11,6 +11,8 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Date; @Service @@ -18,14 +20,20 @@ import java.util.Date; public class ResourceService { public void mdUpload(MdUploadRequest request, MultipartFile file) { - FileUtils.uploadFile(file, FileUtils.MD_IMAGE_DIR, request.getId() + "_" + file.getOriginalFilename()); + FileUtils.uploadFile(file, FileUtils.MD_IMAGE_DIR, request.getId() + "_" + request.getFileName()); } public ResponseEntity getMdImage(String name) { File file = new File(FileUtils.MD_IMAGE_DIR + "/" + name); HttpHeaders headers = new HttpHeaders(); + String fileName = ""; + try { + fileName = URLEncoder.encode(file.getName(), "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } headers.add("Cache-Control", "no-cache, no-store, must-revalidate"); - headers.add("Content-Disposition", "attachment; filename=" + file.getName()); + headers.add("Content-Disposition", "attachment; filename=" + fileName); headers.add("Pragma", "no-cache"); headers.add("Expires", "0"); headers.add("Last-Modified", new Date().toString()); diff --git a/frontend/src/business/components/settings/personal/JiraUserInfo.vue b/frontend/src/business/components/settings/personal/JiraUserInfo.vue index 44e20cab6e..372cc66b8d 100644 --- a/frontend/src/business/components/settings/personal/JiraUserInfo.vue +++ b/frontend/src/business/components/settings/personal/JiraUserInfo.vue @@ -6,7 +6,7 @@ - + diff --git a/frontend/src/business/components/settings/workspace/components/JiraSetting.vue b/frontend/src/business/components/settings/workspace/components/JiraSetting.vue index af911edfe0..06d6a030c2 100644 --- a/frontend/src/business/components/settings/workspace/components/JiraSetting.vue +++ b/frontend/src/business/components/settings/workspace/components/JiraSetting.vue @@ -6,7 +6,7 @@ - + diff --git a/frontend/src/business/components/track/case/components/FormRichTextItem.vue b/frontend/src/business/components/track/case/components/FormRichTextItem.vue index c222fab3c8..7856841fa4 100644 --- a/frontend/src/business/components/track/case/components/FormRichTextItem.vue +++ b/frontend/src/business/components/track/case/components/FormRichTextItem.vue @@ -107,9 +107,11 @@ export default { }; file.prefix = param.id; this.result.loading = true; + // 带括号和空格,可能无法展示 + param.fileName = file.name.replace("(", "").replace(")", "").replace(" ", ""); this.$fileUpload('/resource/md/upload', file, null, param, () => { this.$success(this.$t('commons.save_success')); - this.$refs.md.$img2Url(pos, '/resource/md/get/' + param.id + '_' + file.name); + this.$refs.md.$img2Url(pos, '/resource/md/get/' + param.id + '_' + param.fileName); this.result.loading = false; }); this.$emit('imgAdd', file);