|
@@ -334,13 +334,35 @@ public class PublicServiceImpl implements IPublicService {
|
|
|
* @throws MINBusinessException
|
|
|
* @throws BusinessCodeException
|
|
|
*/
|
|
|
- public Map<String, Object> uploadFile(FileItem file, String fileType, int size, boolean renameFlag)
|
|
|
+ public Map<String, Object> uploadFileBD(FileItem file, String fileType, int size, boolean renameFlag,String channel)
|
|
|
throws MINBusinessException, BusinessCodeException {
|
|
|
String savePath = System.getProperty("catalina.home") + File.separator + "webapps" + File.separator + "upload"
|
|
|
+ File.separator;
|
|
|
+
|
|
|
+ //文件目录
|
|
|
+ String fileTypePath = Service.lookup(IPublicService.class)
|
|
|
+ .getSysParValue(channel+"_FILE_PATH_" + fileType);
|
|
|
+ // 获取当前时间
|
|
|
+ String nowDate = DateUtil.format(new Date(), "yyyyMMdd");
|
|
|
+ // 获取根路径(nginx文件服务器路径)
|
|
|
+ String basePath = Service.lookup(IPublicService.class)
|
|
|
+ .getSysParValue(channel+"_FILE_SERVER_BASE_PATH");// 为nginx根路径
|
|
|
+ savePath = basePath.concat(fileTypePath).concat(nowDate).concat("/");
|
|
|
+
|
|
|
+ // 获取web服务器访问路径
|
|
|
+ String baseUrl = Service.lookup(IPublicService.class)
|
|
|
+ .getSysParValue(channel+"_FILE_SERVER_URL"); // 为nginx访问路径
|
|
|
+ baseUrl = baseUrl.concat(fileTypePath).concat(nowDate).concat("/");
|
|
|
+
|
|
|
File files = new File(savePath);
|
|
|
+
|
|
|
if (!files.exists()) {
|
|
|
- files.mkdir();
|
|
|
+ boolean file_true = files.mkdir();
|
|
|
+ if (file_true) {
|
|
|
+ System.out.println("文件夹建立成功");
|
|
|
+ } else {
|
|
|
+ System.out.println("文件建立失败");
|
|
|
+ }
|
|
|
}
|
|
|
FileOutputStream fs = null;
|
|
|
InputStream in = null;
|
|
@@ -351,13 +373,17 @@ public class PublicServiceImpl implements IPublicService {
|
|
|
fs = new FileOutputStream(saveUrl);
|
|
|
in = file.getInputStream();
|
|
|
FileCopyUtils.copy(in, fs);
|
|
|
+ in.close();
|
|
|
+ fs.flush();
|
|
|
+ fs.close();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+
|
|
|
double width = -1; // 记录图片宽度
|
|
|
double height = -1; // 记录图片的高度
|
|
|
|
|
|
- String baseUrl = Service.lookup(IPublicService.class).getSysParValue("FILE_SERVER_URL"); // 为nginx访问路径
|
|
|
+ //String baseUrl = Service.lookup(IPublicService.class).getSysParValue("FILE_SERVER_URL"); // 为nginx访问路径
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
map.put("url", baseUrl + fileName);
|
|
|
map.put("width", width);
|