I have "file.txt" in my OpenShift PersistentVolumeClaims. My StorageClasses is NFS.
Is it possible to access and read "file.txt" from my spring-boot code? (This spring-boot code will be deployed on OpenShift and I'll mount the PVC to the DeploymentConfigs)
If yes, how can I do that? (I'm confused in how to retrieve the file from persistent volume from inside the code)
Any help will be appreciated. Thanks.
What @larsks said in the comment is correct:
your application doesn't know or care about the fact that you're using a persistent volume
However, I used:
Resource resource = new ClassPathResource("/pvc/mount/path/file.txt");
InputStream inputStream = resource.getInputStream();
and:
Resource resource = resourceLoader.getResource("/pvc/mount/path/file.txt");
InputStream inputStream = resource.getInputStream();
Both doesn't work.
Below is what I use in the end:
Path file = Paths.get("/pvc/mount/path/file.txt");
InputStream stream = Files.newInputStream(file);