diff --git a/src/main/java/dev/urner/volodb/rest/VolunteerRestController.java b/src/main/java/dev/urner/volodb/rest/VolunteerRestController.java index 2d91de4..c09198a 100644 --- a/src/main/java/dev/urner/volodb/rest/VolunteerRestController.java +++ b/src/main/java/dev/urner/volodb/rest/VolunteerRestController.java @@ -32,8 +32,6 @@ import java.util.Map; import java.util.List; import java.time.LocalDateTime; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; @RestController @RequestMapping("/volunteers") @@ -213,8 +211,9 @@ public VolunteerDocument postNewDocument( @PathVariable int volunteerId, @RequestParam MultipartFile document, @RequestParam int documentTypeId, + @RequestParam String documentName, @AuthenticationPrincipal UserPrincipal principal) { - return volunteerService.saveDocument(document, documentTypeId, volunteerId, principal.getUsername()); + return volunteerService.saveDocument(document, documentTypeId, volunteerId, documentName, principal.getUsername()); } // ********************************** diff --git a/src/main/java/dev/urner/volodb/service/VolunteerService.java b/src/main/java/dev/urner/volodb/service/VolunteerService.java index 0480ec6..1c2cde5 100644 --- a/src/main/java/dev/urner/volodb/service/VolunteerService.java +++ b/src/main/java/dev/urner/volodb/service/VolunteerService.java @@ -259,7 +259,8 @@ public String SetAvatar(MultipartFile avatar, int volunteerId) { return dbVolunteer.getAvatar(); } - public VolunteerDocument saveDocument(MultipartFile file, int documentTypeId, int volunteerId, String username) { + public VolunteerDocument saveDocument(MultipartFile file, int documentTypeId, int volunteerId, String documentName, + String username) { String fileExtension = FilenameUtils.getExtension(file.getOriginalFilename()); String bucket = "volunteer-" + volunteerId; String object = "documents/document-" + UUID.randomUUID().toString() + "." + fileExtension; @@ -271,6 +272,7 @@ public VolunteerDocument saveDocument(MultipartFile file, int documentTypeId, in voloDoc.setSize(file.getSize()); voloDoc.setUsername(username); voloDoc.setPath(bucket + "/" + object); + voloDoc.setName(documentName); fileService.saveFile(file, bucket, object); return volunteerDocumentService.save(voloDoc);