use of com.publiccms.entities.log.LogUpload in project PublicCMS-preview by sanluan.
the class FileAdminController method upload.
/**
* @param file
* @param field
* @param originalField
* @param onlyImage
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping(value = "doUpload", method = RequestMethod.POST)
public String upload(MultipartFile file, String field, String originalField, Boolean onlyImage, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
if (null != file && !file.isEmpty()) {
String originalName = file.getOriginalFilename();
String suffix = fileComponent.getSuffix(originalName);
String fileName = fileComponent.getUploadFileName(suffix);
try {
fileComponent.upload(file, siteComponent.getWebFilePath(site, fileName));
model.put("field", field);
model.put(field, fileName);
if (CommonUtils.notEmpty(originalField)) {
model.put("originalField", originalField);
model.put(originalField, originalName);
}
logUploadService.save(new LogUpload(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, onlyImage, file.getSize(), RequestUtils.getIpAddress(request), CommonUtils.getDate(), fileName));
} catch (IllegalStateException | IOException e) {
log.error(e.getMessage(), e);
return "common/uploadResult";
}
}
return "common/uploadResult";
}
use of com.publiccms.entities.log.LogUpload in project PublicCMS-preview by sanluan.
the class UeditorAdminController method uploadScraw.
/**
* @param file
* @param request
* @param session
* @return view name
*/
@RequestMapping(params = "action=" + ACTION_UPLOAD_SCRAW)
@ResponseBody
public Map<String, Object> uploadScraw(String file, HttpServletRequest request, HttpSession session) {
SysSite site = getSite(request);
if (CommonUtils.notEmpty(file)) {
byte[] data = VerificationUtils.base64Decode(file);
String fileName = fileComponent.getUploadFileName(SCRAW_TYPE);
File dest = new File(siteComponent.getWebFilePath(site, fileName));
try {
FileUtils.writeByteArrayToFile(dest, data);
logUploadService.save(new LogUpload(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, true, dest.length(), RequestUtils.getIpAddress(request), CommonUtils.getDate(), fileName));
Map<String, Object> map = getResultMap(true);
map.put("size", data.length);
map.put("title", dest.getName());
map.put("url", fileName);
map.put("type", SCRAW_TYPE);
map.put("original", "scraw" + SCRAW_TYPE);
return map;
} catch (IllegalStateException | IOException e) {
log.error(e.getMessage(), e);
return getResultMap(false);
}
}
return getResultMap(false);
}
use of com.publiccms.entities.log.LogUpload in project PublicCMS-preview by sanluan.
the class SysSiteAdminController method upload.
/**
* @param file
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping(value = "doUploadLicense", method = RequestMethod.POST)
public String upload(MultipartFile file, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
if (ControllerUtils.verifyCustom("noright", !siteComponent.isMaster(site.getId()), model)) {
return TEMPLATE_ERROR;
}
if (null != file && !file.isEmpty()) {
try {
fileComponent.upload(file, siteComponent.getRootPath() + CommonConstants.LICENSE_FILENAME);
logUploadService.save(new LogUpload(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, false, file.getSize(), RequestUtils.getIpAddress(request), CommonUtils.getDate(), CommonConstants.LICENSE_FILENAME));
return TEMPLATE_DONE;
} catch (IllegalStateException | IOException e) {
log.error(e.getMessage(), e);
}
}
return TEMPLATE_ERROR;
}
Aggregations