我正在尝试将数据写入InputStream
而不是写入文件。
我的 Writer 类扩展FlatFileItemWriter
我看到FlatFileItemWriter<>
可以选择将数据写入InputStream
我正在设置这样的资源
setResource(new InputStreamResource(inputStream));
我收到以下错误
org.springframework.batch.item.ItemStreamException: Could not convert resource to file: [InputStream resource [resource loaded through InputStream]]
at org.springframework.batch.item.file.FlatFileItemWriter.getOutputState(FlatFileItemWriter.java:384) ~[spring-batch-infrastructure-3.0.8.RELEASE.jar:3.0.8.RELEASE]
at org.springframework.batch.item.file.FlatFileItemWriter.open(FlatFileItemWriter.java:322) ~[spring-batch-infrastructure-3.0.8.RELEASE.jar:3.0.8.RELEASE]
Caused by: java.io.FileNotFoundException: InputStream resource [resource loaded through InputStream] cannot be resolved to absolute file path
at org.springframework.core.io.AbstractResource.getFile(AbstractResource.java:114) ~[spring-core-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.batch.item.file.FlatFileItemWriter.getOutputState(FlatFileItemWriter.java:381) ~[spring-batch-infrastructure-3.0.8.RELEASE.jar:3.0.8.RELEASE]
可以做些什么来纠正这个问题?或者还有其他方法可以实现吗?
这样做的目的是通过S3Client将流发送到AWS S3 ,这比创建文件实例并上传它更舒服。