Commit 87597fa9 by huluobin

文件上传

parent 0ab93c37
package com.gogirl.infrastructure.service.file.impl; package com.gogirl.infrastructure.service.file.impl;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.StringUtils;
import com.gogirl.infrastructure.config.property.GogirlProperties; import com.gogirl.infrastructure.config.property.GogirlProperties;
import com.gogirl.infrastructure.service.file.FileService; import com.gogirl.infrastructure.service.file.FileService;
import com.google.gson.Gson; import com.google.gson.Gson;
...@@ -32,8 +35,11 @@ public class QiniuFileServiceImpl implements FileService { ...@@ -32,8 +35,11 @@ public class QiniuFileServiceImpl implements FileService {
String picturePath = gogirlProperties.getPicturePath(); String picturePath = gogirlProperties.getPicturePath();
//文件名 //文件名
String fileName = multipartFile.getOriginalFilename(); String fileName = multipartFile.getOriginalFilename();
if (StringUtils.isEmpty(fileName)) {
throw new RRException("上传文件为空,请重新上传");
}
String fileSuffix = fileName.substring(fileName.lastIndexOf(".")); String fileSuffix = fileName.substring(fileName.lastIndexOf("."));
String localFileName = System.currentTimeMillis() + fileSuffix; String localFileName = IdWorker.getId() + fileSuffix;
String filePath = picturePath + File.separator + localFileName; String filePath = picturePath + File.separator + localFileName;
File localFile = new File(filePath); File localFile = new File(filePath);
File imagePath = new File(picturePath); File imagePath = new File(picturePath);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment