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.

@FunctionalInterface public interface UploadHandler
文件上传处理器。 用于处理编辑器中的图片和文件上传。

使用示例:

// 上传到本地文件系统
editor.setUploadHandler((context, stream) -> {
    String filename = context.getFileName();
    Path targetPath = uploadDir.resolve(filename);
    Files.copy(stream, targetPath);
    return CompletableFuture.completedFuture(
        new UploadResult("/uploads/" + filename)
    );
});

// 上传到云存储
editor.setUploadHandler((context, stream) -> {
    return cloudStorage.uploadAsync(stream, context.getFileName())
        .thenApply(url -> new UploadResult(url));
});