diff --git a/framework/sdk-parent/frontend/src/plugins/request.js b/framework/sdk-parent/frontend/src/plugins/request.js index 744b7e59f4..c6c832cd1d 100644 --- a/framework/sdk-parent/frontend/src/plugins/request.js +++ b/framework/sdk-parent/frontend/src/plugins/request.js @@ -1,7 +1,7 @@ import axios from 'axios' import {$error} from "./message" import {getCurrentProjectID, getCurrentWorkspaceId} from "../utils/token"; -import {PROJECT_ID, TokenKey, WORKSPACE_ID, TASK_PATH, TASK_DATA} from "../utils/constants"; +import {PROJECT_ID, TASK_PATH, TokenKey, WORKSPACE_ID} from "../utils/constants"; import packageJSON from '@/../package.json' import {getUrlParams, getUUID} from "../utils"; import {initTaskData} from "../api/novice"; @@ -184,12 +184,12 @@ export function fileUploadWithProcessAndCancel(url, file, param, CancelTokenObj, if (file) { formData.append("file", file); } - formData.append('request', new Blob([JSON.stringify(param)], {type: "application/json"})); + formData.append('sourceId', param); let axiosRequestConfig = { method: 'POST', url: url, data: formData, - headers: {'Content-Type': 'application/json;charset=UTF-8'}, + headers: {'Content-Type': 'multipart/form-data'}, cancelToken: new CancelTokenObj(function executor(c) { cancelFileTokenList.push({"name": file.name, "cancelFunc": c}); }), diff --git a/test-track/backend/src/main/java/io/metersphere/controller/AttachmentController.java b/test-track/backend/src/main/java/io/metersphere/controller/AttachmentController.java index 097905f70e..dbc2cd48bc 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/AttachmentController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/AttachmentController.java @@ -10,8 +10,9 @@ import io.metersphere.i18n.Translator; import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.metadata.service.FileMetadataService; import io.metersphere.request.attachment.AttachmentDumpRequest; -import io.metersphere.xpack.track.dto.AttachmentRequest; import io.metersphere.service.AttachmentService; +import io.metersphere.xpack.track.dto.AttachmentRequest; +import jakarta.annotation.Resource; import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.http.HttpHeaders; @@ -20,7 +21,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import jakarta.annotation.Resource; import java.util.ArrayList; import java.util.List; @@ -39,14 +39,20 @@ public class AttachmentController { @MsAuditLog(module = OperLogModule.TRACK_BUG, type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#request.belongId, #request.belongType, #file.getOriginalFilename(), false)", msClass = AttachmentService.class) @PostMapping(value = "/issue/upload", consumes = {"multipart/form-data"}) @RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ_EDIT) - public void uploadIssueAttachment(@RequestPart("request") AttachmentRequest request, @RequestPart(value = "file", required = false) MultipartFile file) { + public void uploadIssueAttachment(@RequestParam(value = "sourceId") String belongId, @RequestParam(value = "file") MultipartFile file) { + AttachmentRequest request = new AttachmentRequest(); + request.setBelongId(belongId); + request.setBelongType(AttachmentType.ISSUE.type()); attachmentService.uploadAttachment(request, file); } @MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#request.belongId, #request.belongType, #file.getOriginalFilename(), false)", msClass = AttachmentService.class) @PostMapping(value = "/testcase/upload", consumes = {"multipart/form-data"}) @RequiresPermissions(PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT) - public void uploadTestCaseAttachment(@RequestPart("request") AttachmentRequest request, @RequestPart(value = "file", required = false) MultipartFile file) { + public void uploadTestCaseAttachment(@RequestParam(value = "sourceId") String belongId, @RequestParam(value = "file") MultipartFile file) { + AttachmentRequest request = new AttachmentRequest(); + request.setBelongId(belongId); + request.setBelongType(AttachmentType.TEST_CASE.type()); attachmentService.uploadAttachment(request, file); } diff --git a/test-track/frontend/src/business/case/components/case/CaseAttachmentComponent.vue b/test-track/frontend/src/business/case/components/case/CaseAttachmentComponent.vue index f93d25b4dd..4d4da9cfb3 100644 --- a/test-track/frontend/src/business/case/components/case/CaseAttachmentComponent.vue +++ b/test-track/frontend/src/business/case/components/case/CaseAttachmentComponent.vue @@ -112,15 +112,11 @@