Skip to content

Commit

Permalink
fix unique file name constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilWun committed May 17, 2024
1 parent 84ec225 commit 7d80884
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public File create(MultipartFile file) {
}

createdFile.setMimeType(contentType);
createdFile.setFileURL(file.getOriginalFilename());
createdFile.setFileURL(UUID.randomUUID().toString());

final FileData fileData = new FileData();
fileData.setData(inputStream.readAllBytes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public void delete(@NonNull UUID solutionId) {
public File addFileToSolution(UUID solutionId, MultipartFile multipartFile) {
final Solution solution =
ServiceUtils.findById(solutionId, Solution.class, solutionRepository);

if (solution.getFile() != null) {
return solution.getFile();
}

final File file = fileService.create(multipartFile);
solution.setFile(file);
solutionRepository.save(solution);
Expand Down

0 comments on commit 7d80884

Please sign in to comment.