|
@@ -0,0 +1,36 @@
|
|
|
+package com.fdkankan.manage_jp.controller;
|
|
|
+
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.manage_jp.common.Constant;
|
|
|
+import com.fdkankan.manage_jp.common.Result;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/manage_jp/file")
|
|
|
+public class UploadController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ FYunFileServiceInterface fYunFileServiceInterface;
|
|
|
+
|
|
|
+ @PostMapping("/uploadImg")
|
|
|
+ public Result uploadImg(@RequestParam("file") MultipartFile file) throws IOException {
|
|
|
+ Long date = System.currentTimeMillis();
|
|
|
+ String fileName = date + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
|
|
+ String filePath = Constant.AGENT_PATH + "company/" + File.separator + fileName;
|
|
|
+ File targetFile = new File(filePath);
|
|
|
+ if(!targetFile.getParentFile().exists()){
|
|
|
+ targetFile.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+ file.transferTo(targetFile);
|
|
|
+ String url = fYunFileServiceInterface.uploadFile(filePath,"img/".concat(fileName));
|
|
|
+ return Result.success("",url);
|
|
|
+ }
|
|
|
+}
|