|
@@ -1,6 +1,8 @@
|
|
|
package com.caimei.utils;
|
|
|
|
|
|
import com.caimei.modules.fastDFS.FastDFSClient;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Controller;
|
|
@@ -16,6 +18,7 @@ import java.util.*;
|
|
|
@Controller
|
|
|
@RequestMapping("formData")
|
|
|
public class formDataUtils {
|
|
|
+ protected static final Logger logger = LoggerFactory.getLogger(formDataUtils.class);
|
|
|
@Autowired
|
|
|
private FastDFSClient client;
|
|
|
@Value("${malladmin.imageDomain}")
|
|
@@ -24,22 +27,21 @@ public class formDataUtils {
|
|
|
@ResponseBody
|
|
|
@RequestMapping("/MultiPictareaddData")
|
|
|
public Map<String, Object> MultiPictareaddData(MultipartFile[] file, HttpServletRequest request) throws IOException {
|
|
|
- List<String> list = new ArrayList<String>();
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
String saveFile = null;
|
|
|
if (file != null && file.length > 0) {
|
|
|
- System.out.println(file.length);
|
|
|
for (int i = 0; i < file.length; i++) {
|
|
|
MultipartFile filex = file[i];
|
|
|
// 保存文件
|
|
|
saveFile = saveFile(request, filex);
|
|
|
saveFile = imageDomain + "/" + saveFile;
|
|
|
}
|
|
|
- map.put("success", saveFile);
|
|
|
+ map.put("data", saveFile);
|
|
|
map.put("msg", "上传成功");
|
|
|
+ logger.info(">>>>>>>>>>>>>>>>图片上传成功:" + saveFile);
|
|
|
} else {
|
|
|
- System.out.println(file.length + ":长度就是零");
|
|
|
map.put("msg", "上传失败");
|
|
|
+ logger.info(">>>>>>>>>>>>>>>>图片上传失败:");
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
@@ -51,10 +53,9 @@ public class formDataUtils {
|
|
|
int index = originalFilename.lastIndexOf(".");
|
|
|
String exet = originalFilename.substring(index);
|
|
|
String filePath = "/mnt/newdatadrive/data/custom/autodeploy/client/releasecode/mai/mai@beta@2020010900000000/tempImage/";
|
|
|
- System.out.println("filePath=" + filePath);
|
|
|
filePath += "\\" + randomUUID + exet;
|
|
|
- System.out.println(filePath + "P");
|
|
|
- file.transferTo(new File(filePath));// ctrl+1
|
|
|
+ file.transferTo(new File(filePath));
|
|
|
+ logger.info(">>>>>>>>>>>>>>>>图片上传路径:" + filePath);
|
|
|
String file1 = client.uploadFile(filePath);
|
|
|
return file1;
|
|
|
}
|