|
@ -192,7 +192,27 @@ public class FileUploadController extends BaseController {
|
|
|
if(mp3File!=null){
|
|
|
mp3File.delete();
|
|
|
}
|
|
|
}else{
|
|
|
}else if("4".equals(type)){
|
|
|
String tempPath = CommonUtil.saveVoiceToDisk(mf.getInputStream(),fileName);
|
|
|
String pngPath = tempPath.substring(0,tempPath.lastIndexOf("."))+".png";
|
|
|
File tempFile = new File(tempPath);
|
|
|
File pngFile = new File(pngPath);
|
|
|
String times = CommonUtil.getVideoTimeAndImg(tempPath,pngPath);
|
|
|
ObjectNode imgNode = fastDFSUtil.upload(new FileInputStream(pngPath),"png","");
|
|
|
String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
|
|
ObjectNode videoNode = fastDFSUtil.upload(new FileInputStream(tempPath),fileExt,"");
|
|
|
tempPaths.add(fastUrl + imgNode.get("groupName").toString().replaceAll("\"","")
|
|
|
+ "/" + imgNode.get("remoteFileName").toString().replaceAll("\"",""));
|
|
|
tempPaths.add(fastUrl + videoNode.get("groupName").toString().replaceAll("\"","")
|
|
|
+ "/" + videoNode.get("remoteFileName").toString().replaceAll("\"",""));
|
|
|
tempPaths.add(times);
|
|
|
if(tempFile!=null){
|
|
|
tempFile.delete();
|
|
|
}
|
|
|
if(pngFile!=null){
|
|
|
pngFile.delete();
|
|
|
}
|
|
|
} else{
|
|
|
String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
|
|
ObjectNode objectNode = fastDFSUtil.upload(mf.getInputStream() ,fileExt,"");
|
|
|
tempPaths.add(fastUrl + objectNode.get("groupName").toString().replaceAll("\"","")
|
|
@ -202,6 +222,7 @@ public class FileUploadController extends BaseController {
|
|
|
String urls = String.join(",", tempPaths);
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("status", 200);
|
|
|
json.put("success",true);
|
|
|
json.put("msg", "上传成功");
|
|
|
// 图片标识对象的HTTP链接
|
|
|
json.put("urls", urls);
|
|
@ -282,4 +303,45 @@ public class FileUploadController extends BaseController {
|
|
|
return error(-1, "上传失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 语音上传
|
|
|
* @param request
|
|
|
* @param response
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "test", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public String test(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
|
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
|
|
List<String> tempPaths = new ArrayList<String>();
|
|
|
String fastUrl = SystemConf.getInstance().getSystemProperties().getProperty("fastdfs_file_url");
|
|
|
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
|
|
MultipartFile mf = entity.getValue();
|
|
|
String fileName = mf.getOriginalFilename();
|
|
|
String tempPath = CommonUtil.saveVoiceToDisk(mf.getInputStream(),fileName);
|
|
|
String pngPath = tempPath.substring(0,tempPath.lastIndexOf("."))+".png";
|
|
|
File tempFile = new File(tempPath);
|
|
|
File pngFile = new File(pngPath);
|
|
|
String times = CommonUtil.getVideoTimeAndImg(tempPath,pngPath);
|
|
|
ObjectNode imgNode = fastDFSUtil.upload(new FileInputStream(pngPath),"png","");
|
|
|
String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
|
|
ObjectNode videoNode = fastDFSUtil.upload(new FileInputStream(tempPath),fileExt,"");
|
|
|
tempPaths.add(fastUrl + imgNode.get("groupName").toString().replaceAll("\"","")
|
|
|
+ "/" + imgNode.get("remoteFileName").toString().replaceAll("\"",""));
|
|
|
tempPaths.add(fastUrl + videoNode.get("groupName").toString().replaceAll("\"","")
|
|
|
+ "/" + videoNode.get("remoteFileName").toString().replaceAll("\"",""));
|
|
|
tempPaths.add(times);
|
|
|
if(tempFile!=null){
|
|
|
tempFile.delete();
|
|
|
}
|
|
|
if(pngFile!=null){
|
|
|
pngFile.delete();
|
|
|
}
|
|
|
}
|
|
|
String urls = String.join(",", tempPaths);
|
|
|
return urls;
|
|
|
}
|
|
|
}
|