【更新】修复阿里云上传文件地址返回错误,修复文件key构造错误

pull/60/MERGE
xuyuxiang 2 years ago committed by 小诺
parent 6634bdf0e6
commit 7e9ccac572

@ -241,9 +241,9 @@ public class DevFileServiceImpl extends ServiceImpl<DevFileMapper, DevFile> impl
String fileObjectName = fileId + StrUtil.DOT + fileSuffix;
// 获取日期文件夹格式如2021/10/11/
String dateFolderPath = DateUtil.thisYear() + FileUtil.FILE_SEPARATOR +
(DateUtil.thisMonth() + 1) + FileUtil.FILE_SEPARATOR +
DateUtil.thisDayOfMonth() + FileUtil.FILE_SEPARATOR;
String dateFolderPath = DateUtil.thisYear() + StrUtil.SLASH +
(DateUtil.thisMonth() + 1) + StrUtil.SLASH +
DateUtil.thisDayOfMonth() + StrUtil.SLASH;
// 返回
return dateFolderPath + fileObjectName;

@ -33,6 +33,7 @@ import javax.activation.MimetypesFileTypeMap;
import java.io.*;
import java.net.URL;
import java.util.Date;
import java.util.List;
/**
*
@ -429,7 +430,8 @@ public class DevFileAliyunUtil {
try {
initClient();
OSSClient ossClient = (OSSClient) client;
return bucketName + StrUtil.DOT + ossClient.getEndpoint().toString() + StrUtil.SLASH + key;
List<String> urlList = StrUtil.split(ossClient.getEndpoint().toString(), StrUtil.COLON + StrUtil.SLASH + StrUtil.SLASH);
return urlList.get(0) + StrUtil.COLON + StrUtil.SLASH + StrUtil.SLASH + bucketName + StrUtil.DOT + urlList.get(1) + StrUtil.SLASH + key;
} catch (OSSException | ClientException e) {
throw new CommonException(e.getMessage());
}

Loading…
Cancel
Save