Commit e4439848 by huluobin

Merge branch 'master' into 3.7

# Conflicts:
#	src/main/java/com/gogirl/infrastructure/service/file/impl/QiniuFileServiceImpl.java
#	src/main/java/com/gogirl/interfaces/user/FileController.java
parents a52e8335 5b3b0904
package com.gogirl.infrastructure.service.file.impl;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
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.service.file.FileService;
import com.google.gson.Gson;
......@@ -33,6 +36,9 @@ public class QiniuFileServiceImpl implements FileService {
String picturePath = gogirlProperties.getPicturePath();
//文件名
String fileName = multipartFile.getOriginalFilename();
if (StringUtils.isEmpty(fileName)) {
throw new RRException("上传文件为空,请重新上传");
}
String fileSuffix = fileName.substring(fileName.lastIndexOf("."));
String localFileName = IdWorker.getId() + fileSuffix;
String filePath = picturePath + File.separator + localFileName;
......
......@@ -28,6 +28,7 @@ public class FileController {
if (file == null) {
throw new RRException("上传内容为空");
}
public JsonResult<String> upload(MultipartFile file) throws Exception {
log.info("图片上传");
String imgUrl = fileService.saveImage(file);
return JsonResult.success(imgUrl);
......
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