|
@@ -7,6 +7,7 @@ import com.tianbo.warehouse.util.Date.DateUtil; |
|
@@ -7,6 +7,7 @@ import com.tianbo.warehouse.util.Date.DateUtil; |
7
|
import com.tianbo.warehouse.util.Helper;
|
7
|
import com.tianbo.warehouse.util.Helper;
|
8
|
import org.apache.commons.io.FileUtils;
|
8
|
import org.apache.commons.io.FileUtils;
|
9
|
import org.springframework.beans.factory.annotation.Autowired;
|
9
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
10
|
+import org.springframework.beans.factory.annotation.Value;
|
10
|
import org.springframework.web.bind.annotation.PostMapping;
|
11
|
import org.springframework.web.bind.annotation.PostMapping;
|
11
|
import org.springframework.web.bind.annotation.RequestParam;
|
12
|
import org.springframework.web.bind.annotation.RequestParam;
|
12
|
import org.springframework.web.bind.annotation.RestController;
|
13
|
import org.springframework.web.bind.annotation.RestController;
|
|
@@ -23,6 +24,8 @@ public class UploadController { |
|
@@ -23,6 +24,8 @@ public class UploadController { |
23
|
@Autowired
|
24
|
@Autowired
|
24
|
private AttachmentService attachmentService;
|
25
|
private AttachmentService attachmentService;
|
25
|
|
26
|
|
|
|
27
|
+ @Value("${web.upload-path}")
|
|
|
28
|
+ private String uploadPath; // =./upload/
|
26
|
/**
|
29
|
/**
|
27
|
* 单个文件上传
|
30
|
* 单个文件上传
|
28
|
* @param file
|
31
|
* @param file
|
|
@@ -37,9 +40,8 @@ public class UploadController { |
|
@@ -37,9 +40,8 @@ public class UploadController { |
37
|
String fileLitleName = file.getName();
|
40
|
String fileLitleName = file.getName();
|
38
|
String fileName = file.getOriginalFilename();
|
41
|
String fileName = file.getOriginalFilename();
|
39
|
String fileType = fileName.substring((fileName.lastIndexOf(".")));
|
42
|
String fileType = fileName.substring((fileName.lastIndexOf(".")));
|
40
|
- String saveDir = readProperties("uploadDirectory");
|
|
|
41
|
StringBuffer stringBuffer = new StringBuffer();
|
43
|
StringBuffer stringBuffer = new StringBuffer();
|
42
|
- String saveFileName = stringBuffer.append(saveDir).append("/").append(DateUtil.getToday()).append("/").append(Helper.getUUID()).append(fileType).toString();
|
44
|
+ String saveFileName = stringBuffer.append(uploadPath).append(DateUtil.getToday()).append("/").append(Helper.getUUID()).append(fileType).toString();
|
43
|
File saveFile = new File(saveFileName);
|
45
|
File saveFile = new File(saveFileName);
|
44
|
if(!saveFile.getParentFile().exists()){
|
46
|
if(!saveFile.getParentFile().exists()){
|
45
|
saveFile.mkdirs();
|
47
|
saveFile.mkdirs();
|