diff --git a/backend/src/main/java/io/metersphere/controller/TestPlanController.java b/backend/src/main/java/io/metersphere/controller/TestPlanController.java new file mode 100644 index 0000000000..48d4f27dca --- /dev/null +++ b/backend/src/main/java/io/metersphere/controller/TestPlanController.java @@ -0,0 +1,22 @@ +package io.metersphere.controller; + +import io.metersphere.service.FileService; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.IOException; + +@RestController +@RequestMapping(value = "/testplan") +public class TestPlanController { + @Resource + private FileService fileService; + + @PostMapping("/file/upload") + public void upload(MultipartFile file) throws IOException { + fileService.upload(file.getOriginalFilename(), file); + } +} diff --git a/backend/src/main/java/io/metersphere/service/FileService.java b/backend/src/main/java/io/metersphere/service/FileService.java new file mode 100644 index 0000000000..f6b7090a73 --- /dev/null +++ b/backend/src/main/java/io/metersphere/service/FileService.java @@ -0,0 +1,18 @@ +package io.metersphere.service; + +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.stream.Collectors; + +@Service +public class FileService { + public void upload(String name, MultipartFile file) throws IOException { + String result = new BufferedReader(new InputStreamReader(file.getInputStream())) + .lines().collect(Collectors.joining("\n")); + System.out.println(String.format("upload file: %s, content: \n%s", name, result)); + } +} \ No newline at end of file diff --git a/frontend/src/performance/components/testPlan/CreateTestPlan.vue b/frontend/src/performance/components/testPlan/CreateTestPlan.vue index 6b78f60479..3be9afc501 100644 --- a/frontend/src/performance/components/testPlan/CreateTestPlan.vue +++ b/frontend/src/performance/components/testPlan/CreateTestPlan.vue @@ -1,6 +1,6 @@