Skip to content

Instantly share code, notes, and snippets.

@sebastienvermeille
Created May 7, 2021 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastienvermeille/7dd82a79e5255c25c775895b922823e8 to your computer and use it in GitHub Desktop.
Save sebastienvermeille/7dd82a79e5255c25c775895b922823e8 to your computer and use it in GitHub Desktop.
public Mono<Blob> save(final FilePart filePart) {
final var storageUUID = UUID.randomUUID();
final var uploadDir = new File(UPLOAD_DIR + storageUUID);
return filePart.transferTo(uploadDir).flatMap(unused -> {
final var blobb = Blob.builder()
.uuid(storageUUID)
.originalFileName(filePart.filename())
.extension(getExtension(filePart.filename()).orElse(null))
.build();
return blobRepository.save(blobb);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment