I'm reading a file from AWS S3 using resourceLoader.getResource
in my Spring Batch application but I'm getting the below exception:
Caused by: java.lang.IllegalStateException: Input resource must exist (reader is in 'strict' mode): class path resource [s3://myProduct/app/dev/product/input1]
I tried multiple solutions like using PathResource
and other approaches but nothing worked out. Can someone please help me to resolve this issue? Please find my reader
method below:
@Bean
@StepScope
public FlatFileItemReader<String> fileReader() {
String bucketName = "myProduct";
String key = "app/dev/product/input1";
FlatFileItemReader reader = new FlatFileItemReader<>();
reader.setResource(resourceLoader.getResource("s3://" +bucketName + "/" +key));
reader.setLineMapper(new DefaultLineMapper());
return reader;
}