|
@@ -0,0 +1,38 @@
|
|
|
+package com.fdkankan.contro.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.fdkankan.contro.common.Result;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+@Log4j2
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/file/")
|
|
|
+public class ApiFileController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
+ /**
|
|
|
+ * 上传文件
|
|
|
+ * @param file
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "upload", method = RequestMethod.POST)
|
|
|
+ public Result uploadFile(String key, @RequestParam("file") MultipartFile file) throws Exception {
|
|
|
+ if(ObjectUtils.isEmpty(key) || ObjectUtils.isEmpty(file)){
|
|
|
+ log.error("参数有误!");
|
|
|
+ return Result.failure("参数有误!");
|
|
|
+ }
|
|
|
+ fYunFileService.uploadFile(file.getInputStream(),key);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+}
|