use of ua.springboot.web.entity.UploadFile in project Logos_Materials_October_2017 by VolodymyrZavada.
the class UploadFileController method saveFileToDatabase.
@PostMapping("/upload")
public String saveFileToDatabase(@RequestParam("fileUpload") MultipartFile file) throws IOException {
if (file != null) {
// id = null
UploadFile uploadFile = new UploadFile();
uploadFile.setFileName(file.getOriginalFilename());
uploadFile.setFileData(file.getBytes());
uploadFileService.saveFile(uploadFile);
// uploadFile ->
}
return "redirect:/file/upload";
}
use of ua.springboot.web.entity.UploadFile in project Logos_Materials_October_2017 by VolodymyrZavada.
the class UploadFileController method showImageFromDB.
@GetMapping("/preview")
public String showImageFromDB(Model model) {
UploadFile file = fileService.findFileById(1);
String encodeFile = new String(Base64.encodeBase64(file.getFileData()));
model.addAttribute("imageSrc", encodeFile);
return "file/preview";
}
use of ua.springboot.web.entity.UploadFile in project Logos_Materials_October_2017 by VolodymyrZavada.
the class UploadFileController method saveFileTODatabase.
@PostMapping("/upload")
public String saveFileTODatabase(@RequestParam("fileUpload") MultipartFile file) throws IOException {
if (!file.isEmpty() && file != null) {
UploadFile uploadFile = new UploadFile();
// System.out.println("ID: " + uploadFile.getId());
uploadFile.setFileName(file.getOriginalFilename());
uploadFile.setFileData(file.getBytes());
fileService.saveFile(uploadFile);
// System.out.println("ID: " + uploadFile.getId());
}
return "redirect:/file/upload";
}
Aggregations