Browse Source

上传文件命名

zishan-an 11 months ago
parent
commit
d02f34a069
1 changed files with 6 additions and 4 deletions
  1. 6 4
      src/main/java/com/kexun/controller/UploadController.java

+ 6 - 4
src/main/java/com/kexun/controller/UploadController.java

@@ -51,10 +51,11 @@ public class UploadController {
     private String jsonTargetPath;
     private String jsonTargetPath;
 
 
     @PostMapping("/uploadUi")
     @PostMapping("/uploadUi")
-    public Result uploadUi(@RequestParam("files") MultipartFile[] files ) {
+    public Result uploadUi(@RequestParam("files") MultipartFile[] files ,@RequestParam("customerName") String customerName,
+                           @RequestParam("headInfId") String headInfId) {
         if(files.length>0) {
         if(files.length>0) {
             for(MultipartFile file : files) {
             for(MultipartFile file : files) {
-                String fileName = file.getOriginalFilename();
+                String fileName = customerName+"_"+headInfId+"_"+file.getOriginalFilename();
                 try{
                 try{
                     String filePath = "";
                     String filePath = "";
                     if(fileName.endsWith("xml")){
                     if(fileName.endsWith("xml")){
@@ -95,10 +96,11 @@ public class UploadController {
     }
     }
 
 
     @PostMapping("/uploadMod")
     @PostMapping("/uploadMod")
-    public Result uploadMod(@RequestParam("files") MultipartFile[] files ) {
+    public Result uploadMod(@RequestParam("files") MultipartFile[] files ,@RequestParam("customerName") String customerName,
+                            @RequestParam("headInfId") String headInfId) {
         if(files.length>0) {
         if(files.length>0) {
             for(MultipartFile file : files) {
             for(MultipartFile file : files) {
-                String fileName = file.getOriginalFilename();
+                String fileName = customerName+"_"+headInfId+"_"+file.getOriginalFilename();
                 try{
                 try{
                     File mkdir = new File(modelPath);
                     File mkdir = new File(modelPath);
                     if(!mkdir.exists()) {
                     if(!mkdir.exists()) {