:bug:修复上传失败问题

This commit is contained in:
hello-hao
2024-01-11 17:03:48 +08:00
parent fb9f2a896e
commit 3e4c90c8d9
3 changed files with 8 additions and 4 deletions
@@ -44,7 +44,7 @@ public class IndexController {
@Autowired private IRedisService iRedisService;
@Autowired private AppClientService appClientService;
public static String version = "20240102";
public static String version = "20240111";
@RequestMapping(value = "/")
public String Welcome(Model model, HttpServletRequest httpServletRequest) {
model.addAttribute("name", "服务端程序(开源版)");
@@ -131,10 +131,9 @@ public class ImgServiceImpl implements ImgService {
if(sysConfig.getCheckduplicate().equals("1")){
//查重
Images img = new Images();
img.setUserid(user.getId());
img.setUserid(user==null?0:user.getId());
img.setMd5key(images.getMd5key());
List<Images> list = imgMapper.selectImgUrlByMD5(img);
jsonObject.put("url", list.get(0).getImgurl());
if (list.size() > 0) {
jsonObject.put("url", list.get(0).getImgurl());
jsonObject.put("name", flilename);
@@ -129,6 +129,11 @@ public class UploadServicel {
}
}
}
// 判断路径格式 处理一下,去掉最前面的/
String RootPath = key.getRootPath().replace(" ", "");
if (!RootPath.equals("/")) {
updatePath = RootPath.substring(1) + "/" + updatePath;
}
// 先存数据库
Images imgObj = new Images();
String imgnameEd = null;
@@ -176,6 +181,7 @@ public class UploadServicel {
}
long stime = System.currentTimeMillis();
System.out.println("上传前地址:"+updatePath);
ReturnImage returnImage = getSource.storageSource(key.getStorageType(), map, updatePath, key.getId());
if (returnImage.getCode().equals("200")) {
long etime = System.currentTimeMillis();
@@ -215,7 +221,6 @@ public class UploadServicel {
String md5 = jsonObj.getString("md5");
String classifications = jsonObj.getString("classifications");
Integer day = jsonObj.getInteger("day");
String source = jsonObj.getString("source");
String imgIdentifier = jsonObj.getString("imgIdentifier");
JSONArray jsonArray = new JSONArray();
classifications = classifications==null?"":classifications;