|
@@ -22,9 +22,12 @@ import java.nio.file.Files;
|
|
|
@RequestMapping("/auto/upload")
|
|
@RequestMapping("/auto/upload")
|
|
|
public class UploadServlet {
|
|
public class UploadServlet {
|
|
|
|
|
|
|
|
- @Value("${image-url}")
|
|
|
|
|
|
|
+ @Value("${image.url}")
|
|
|
private String imageUrl;
|
|
private String imageUrl;
|
|
|
|
|
|
|
|
|
|
+ @Value("${image.path}")
|
|
|
|
|
+ private String imagePath;
|
|
|
|
|
+
|
|
|
@PostMapping("/save")
|
|
@PostMapping("/save")
|
|
|
protected CommonResult doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
protected CommonResult doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
// 获取文件内容
|
|
// 获取文件内容
|
|
@@ -34,8 +37,8 @@ public class UploadServlet {
|
|
|
String fileNameWithPath = FileUtil.getFileNameWithPath() + ".jpg";
|
|
String fileNameWithPath = FileUtil.getFileNameWithPath() + ".jpg";
|
|
|
// FileUtil.makeDirs(fileNameWithPath, "E://image3");
|
|
// FileUtil.makeDirs(fileNameWithPath, "E://image3");
|
|
|
// String imgFilePath = "E://image3/" + fileNameWithPath;
|
|
// String imgFilePath = "E://image3/" + fileNameWithPath;
|
|
|
- FileUtil.makeDirs(fileNameWithPath, "/usr/local/nginx/html/image");
|
|
|
|
|
- String imgFilePath = "/usr/local/nginx/html/image/" + fileNameWithPath;
|
|
|
|
|
|
|
+ FileUtil.makeDirs(fileNameWithPath, imagePath);
|
|
|
|
|
+ String imgFilePath = imagePath+"/" + fileNameWithPath;
|
|
|
|
|
|
|
|
// 上传图片
|
|
// 上传图片
|
|
|
Files.copy(fileContent,new File(imgFilePath).toPath());
|
|
Files.copy(fileContent,new File(imgFilePath).toPath());
|