java - 如何使用 Spring Reactive webflux 在 Mongodb 中保存 excel 文件的数据?
问题描述
我想将我的byte[]
数据上传到我的 mongodb 中,但我不知道该怎么做,我可以在非反应式使用中做到这一点,InputStream
但我不确定如何在反应式中做到这一点。我尝试了一些东西,但没有奏效。
我的服务方式
public Mono<Void> upload(String id){
return Repository.findById(id)
.map(p->{byte[] byte=p.getExcel();return byte;})
.map(byte -> {
InputStream file=new ByteArrayInputStream(byte);
List<Data> ex= Helper.exceltodata(file);
return DataRepository.saveAll(ex);
}).switchIfEmpty(Mono.error(new ResponseStatusException(HttpStatus.BAD_REQUEST,"unsuccessful"))).subscribe();
}
我应该如何正确地做到这一点?
解决方案
推荐阅读
- indy - 在 D2005 中使用 TIdHTTPServer 线程安全
- linux - 提取和重新格式化字符串/时间键之间的文本
- java - java.util.IllegalFormatFlagsException:标志=''
- websocket - 建立连接后,我可以将分配添加到“主套接字”吗?
- windows - 修改“.img”的现有 Windows 上下文
- php - 如何使用 Laravel 和基本 URL 将图像存储在数据库中
- amp-html - AMP 页面正常,但点击时不可见(空)
- java - 提取带有 - 包含的大写小写的单词不适用于仅提取字符的单词
- laravel - Laravel 5.5 会话文件不存储在生产服务器的存储/框架/会话中
- regex - Flutter 无法解析正则表达式