Commit e8879dcd authored by 周健威's avatar 周健威

修改代码

parent e7397491
...@@ -81,9 +81,11 @@ public class DataTempcacheController extends BaseController<DataTempcacheBiz,Dat ...@@ -81,9 +81,11 @@ public class DataTempcacheController extends BaseController<DataTempcacheBiz,Dat
baseBiz.insertSelective(dataTempcache); baseBiz.insertSelective(dataTempcache);
} }
String realPath = tempcachePath+"/"+dataTempcache.getId();
String serverPath = baseUploadPath + realPath;
//创建目录 //创建目录
if(!FileUtil.exist(baseUploadPath+tempcachePath+"/"+dataTempcache.getId())) { if(!FileUtil.exist(serverPath)) {
FileUtil.mkdir(baseUploadPath+tempcachePath+"/"+dataTempcache.getId()); FileUtil.mkdir(serverPath);
} }
String fileName = StrUtil.subAfter(dataTempcache.getUpurl(), "/", true); String fileName = StrUtil.subAfter(dataTempcache.getUpurl(), "/", true);
...@@ -99,12 +101,12 @@ public class DataTempcacheController extends BaseController<DataTempcacheBiz,Dat ...@@ -99,12 +101,12 @@ public class DataTempcacheController extends BaseController<DataTempcacheBiz,Dat
} }
//下载文件 //下载文件
Long size = HttpUtil.downloadFile(dataTempcache.getUpurl(), FileUtil.file(baseUploadPath+tempcachePath+"/"+dataTempcache.getFilename())); Long size = HttpUtil.downloadFile(dataTempcache.getUpurl(), FileUtil.file(serverPath + "/" + dataTempcache.getFilename()));
double fileSizeInMB = (double) size / (1024 * 1024); // 转换为 MB double fileSizeInMB = (double) size / (1024 * 1024); // 转换为 MB
double roundedFileSizeInMB = Math.round(fileSizeInMB * 100.0) / 100.0; // 保留两位小数 double roundedFileSizeInMB = Math.round(fileSizeInMB * 100.0) / 100.0; // 保留两位小数
String fileSizeString = String.format("%.2f MB", roundedFileSizeInMB); String fileSizeString = String.format("%.2f MB", roundedFileSizeInMB);
dataTempcache.setFilesize(fileSizeString); dataTempcache.setFilesize(fileSizeString);
dataTempcache.setFileurl(xx_url+ SystemConfig.XXMP_URL + tempcachePath + "/" + dataTempcache.getFilename()); dataTempcache.setFileurl(xx_url+ SystemConfig.XXMP_URL + realPath + "/" + dataTempcache.getFilename());
} }
} }
......
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