【发布时间】:2021-08-03 06:16:56
【问题描述】:
我希望在保存文件后返回 Mono.just(file.getAbsolutePath())。以下是我的代码:
public Mono<String> save(Mono<FilePart> filePartMono) {
Mono<String> monoString = filePartMono.flatMap(filePart -> {
File file = new File(filePart.filename());
if (file.exists()) {
file.delete();
LOG.info("existing file deleted: {}", file.getAbsolutePath());
}
Mono<Void> mono = filePart.transferTo(file);
LOG.info("file saved: {}", file.getAbsolutePath());
return Mono.just(file.getAbsolutePath());
}).thenReturn("hello");
return monoString;
现在我正在返回一个“你好”。有没有办法从我的 save() 方法中返回 file.getAbsolutePath() 而不是字符串?
【问题讨论】: