Interface UploadHandler
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
File upload handler.
Handles image and file uploads in the editor.
Usage examples:
// Upload to local filesystem
editor.setUploadHandler((context, stream) -> {
String filename = context.getFileName();
Path targetPath = uploadDir.resolve(filename);
Files.copy(stream, targetPath);
return CompletableFuture.completedFuture(
new UploadResult("/uploads/" + filename)
);
});
// Upload to cloud storage
editor.setUploadHandler((context, stream) -> {
return cloudStorage.uploadAsync(stream, context.getFileName())
.thenApply(url -> new UploadResult(url));
});
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classUpload configurationstatic classUpload contextstatic classUpload result -
Method Summary
Modifier and TypeMethodDescriptionhandleUpload(UploadHandler.UploadContext context, InputStream inputStream) Handle file upload
-
Method Details
-
handleUpload
CompletableFuture<UploadHandler.UploadResult> handleUpload(UploadHandler.UploadContext context, InputStream inputStream) Handle file upload- Parameters:
context- upload context informationinputStream- file input stream- Returns:
- asynchronous upload result
-