@RequestMapping(value = "/uploadFile")
public void uploadPAD(@RequestParam("File") MultipartFile filelist,HttpServletRequest request,HttpServletResponse response,HttpSession session) throws UnsupportedEncodingException{
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
String cinema_codes = request.getParameter("cinema_code");
JSONObject json = new JSONObject();
String returnInfo = "";
String uplaodFileName = null;//上传的文件全路径名
for(String cinema_code : cinema_codes.toString().split(",")){
if(StringUtils.isNotBlank(cinema_code)){
String webPath =BaseUtil.readValue("CDN_MOVIE_PATH") + "version/";
// String webPath = "D:/version/";
webPath += cinema_code;
if(!filelist.isEmpty()){
try {
// 文件操作
try {
uplaodFileName = filelist.getOriginalFilename();
// 判断是否存在上传文件夹 无则创建
File dirPath = new File(webPath);
if (!dirPath.exists()) {
dirPath.mkdirs();
}
for (File file : dirPath.listFiles()) {
if (uplaodFileName.equals(file.getName())) {
FileUtil.deleteFile(file.toString());
}
}
// 创建文件
File uploadFile = new File(webPath +"/"+ uplaodFileName);
// Copy文件
FileCopyUtils.copy(filelist.getBytes(), uploadFile);
returnInfo = "上传成功 !";
} catch (Exception e) {
logger.error("uploadlist error", e);
returnInfo = "上传文件出错 !";
throw e;
}
// 操作日志
ExceptionUtils.addException(ExceptionUtils.USR_LOG,"上传版本文件成功", returnInfo, null, session,tms_OperationLogService);
} catch (Exception e) {
logger.error("uploadlist error", e);
if (returnInfo == null || "".equals(returnInfo)) {
returnInfo = "APK上传异常 !";
}
ExceptionUtils.addException(ExceptionUtils.EXCEPTION_LOG,"上传版本文件失败", returnInfo, e, session,tms_OperationLogService);
}
} else {
returnInfo = "文件没找到或无内容 , 请检查 !";
}
}
}
try {
json.put("returnInfo", returnInfo);
PrintWriter writer = response.getWriter();//将JSON数据返回给前台
writer.write(json.toString());
writer.close();
} catch (Exception e) {
}
}
public void uploadPAD(@RequestParam("File") MultipartFile filelist,HttpServletRequest request,HttpServletResponse response,HttpSession session) throws UnsupportedEncodingException{
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
String cinema_codes = request.getParameter("cinema_code");
JSONObject json = new JSONObject();
String returnInfo = "";
String uplaodFileName = null;//上传的文件全路径名
for(String cinema_code : cinema_codes.toString().split(",")){
if(StringUtils.isNotBlank(cinema_code)){
String webPath =BaseUtil.readValue("CDN_MOVIE_PATH") + "version/";
// String webPath = "D:/version/";
webPath += cinema_code;
if(!filelist.isEmpty()){
try {
// 文件操作
try {
uplaodFileName = filelist.getOriginalFilename();
// 判断是否存在上传文件夹 无则创建
File dirPath = new File(webPath);
if (!dirPath.exists()) {
dirPath.mkdirs();
}
for (File file : dirPath.listFiles()) {
if (uplaodFileName.equals(file.getName())) {
FileUtil.deleteFile(file.toString());
}
}
// 创建文件
File uploadFile = new File(webPath +"/"+ uplaodFileName);
// Copy文件
FileCopyUtils.copy(filelist.getBytes(), uploadFile);
returnInfo = "上传成功 !";
} catch (Exception e) {
logger.error("uploadlist error", e);
returnInfo = "上传文件出错 !";
throw e;
}
// 操作日志
ExceptionUtils.addException(ExceptionUtils.USR_LOG,"上传版本文件成功", returnInfo, null, session,tms_OperationLogService);
} catch (Exception e) {
logger.error("uploadlist error", e);
if (returnInfo == null || "".equals(returnInfo)) {
returnInfo = "APK上传异常 !";
}
ExceptionUtils.addException(ExceptionUtils.EXCEPTION_LOG,"上传版本文件失败", returnInfo, e, session,tms_OperationLogService);
}
} else {
returnInfo = "文件没找到或无内容 , 请检查 !";
}
}
}
try {
json.put("returnInfo", returnInfo);
PrintWriter writer = response.getWriter();//将JSON数据返回给前台
writer.write(json.toString());
writer.close();
} catch (Exception e) {
}
}