Skip to content

Commit

Permalink
Add log to multipleUpload static resources
Browse files Browse the repository at this point in the history
  • Loading branch information
EmanueleValentini1 committed Oct 15, 2024
1 parent de7d03a commit e4d35d2
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ private void validateFileExtension(String filename, List<String> validExtensions
public Uni<List<String>> createResourceMultiple(List<ResourceEntity> resourceEntityList, List<ResourceCreationDto> resourceCreationDtoList) {
List<String> errors = new ArrayList<>();
List<String> uploadedFiles = new ArrayList<>();

long totalFileSize = resourceCreationDtoList.stream()
.mapToLong(dto -> dto.getFile().length()) // ottieni la dimensione del file in byte
.sum();

// Se la somma delle dimensioni dei file supera 10MB, solleva un'eccezione
if (totalFileSize > 10 * 1024 * 1024) {
throw new AtmLayerException("La dimensione totale dei file supera il limite di 10MB", Response.Status.INTERNAL_SERVER_ERROR, ATMLM_500);
}

return Multi.createFrom().items(resourceEntityList.stream())
.onItem().transformToUniAndConcatenate(resourceEntity -> {
int index = resourceEntityList.indexOf(resourceEntity);
Expand Down Expand Up @@ -208,6 +218,7 @@ public Uni<List<String>> createResourceMultiple(List<ResourceEntity> resourceEnt
});
})
.onFailure().recoverWithItem(throwable -> {
log.error("Error processing file {}: {}", filename, throwable.getMessage());
errors.add(String.format("%s: %s", filename, throwable.getMessage()));
return null;
});
Expand Down

0 comments on commit e4d35d2

Please sign in to comment.