Untitled

mail@pastecode.io avatar
unknown
java
a month ago
709 B
1
Indexable
Never
@PostMapping("database/upload")
@Operation(summary = "Upload file into database", description = "It uploads files into the database as a binary.")
public void fileToDatabase(@RequestParam("files") MultipartFile file) {
        long startTime = System.nanoTime();

        Image newImage = new Image();
        try {
            newImage.setData(file.getBytes());
            newImage.setFileName(file.getOriginalFilename());
        } catch (IOException e) {
            log.error(e.getMessage());
        }
        this.fileService.saveAllFilesToDatabase(newImage);
        long endTime = System.nanoTime() - startTime;
        timeLogger.logTimeInFile(endTime, "database", file.getOriginalFilename());
    }
Leave a Comment