@RequestMapping("user-base-upload")
@ResponseBody
public String upload(@RequestParam(value = "id", required = false) Long id,
@RequestParam("avatar") MultipartFile avatar,
HttpSession httpSession) throws Exception {
StoreDTO storeDto = storeConnector
.save("avatar", new MultipartFileResource(avatar),
avatar.getOriginalFilename());
if (id != null) {
UserBase userBase = userBaseManager.get(id);
userBase.setAvatar(storeDto.getKey());
userBaseManager.save(userBase);
} else {
httpSession.setAttribute("temporaryAvatar", storeDto.getKey());
}
return "{\"success\":true,\"id\":\"" + ((id == null) ? "" : id) + "\"}";
}