【发布时间】:2022-01-21 21:32:32
【问题描述】:
我想将文件上传到 minio 文件容器。
较小的文件可以使用此代码按预期工作:
private Mono<Boolean> saveFileToMinio(FilePart filePart) {
log.info("About to save database to minio container...");
Mono<Boolean> result = Mono.from(
filePart.content().flatMap(dataBuffer -> {
var bytes = dataBuffer.asByteBuffer().array();
dataBuffer.read(bytes);
DataBufferUtils.release(dataBuffer);
return Flux.just(bytes);
})
.flatMap(databaseFileService::write)
.then(Mono.just(true))
.onErrorMap(throwable -> {
log.error(throwable.getMessage(), throwable);
return throwable;
}));
log.info("Successfully saved database to minio container...");
return result;
}
我需要提供byte[] 以便上传我的 minio 服务。
较小的文件按预期工作(将存储到容器中)。但较大的文件(我的测试中为 12 MB)不起作用。
我得到了这个例外:java.lang.IndexOutOfBoundsException: readPosition 0 and length 1024 should be smaller than writePosition 808
【问题讨论】:
标签: spring-webflux project-reactor