We have a Windows file share with JPEGs that I'm trying to access from Pivotal Cloud Foundry via a Java Spring Boot REST API. What are the steps needed in both PCF and Java itself to achieve this?
Do I have to mount the drive in PCF first, then I can use the standard java.io libraries somehow to access this file? As of now we are simply wanting to read the JPEG files into a BufferedImage and return them as Base64 after some graphics manipulation (which I know how to do), but I'm stuck on getting my head around what to do for this within the realm of PCF. Obviously, it works just fine on my Windows development machine where my logged-in user also has credentials to the file share and no need to mount it or do anything special.
I keep reading about SMB and a JCIFS library online, but still not sure if this is what I need or how to fully apply this with the technologies at hand.
Starting in Pivotal Cloud Foundry 2.4, you are able to enable SMB volume services. This allows you to cf create-service
a volume service that points to your SMB server. You can then bind that to your app, and when your app starts the platform will mount the SMB volume to the mount point you specify. At that point, your app would just need to know the mount point, like /smb
or /files
, so it could use standard Java I/O to read in the files.
If you are a platform operator, the instructions for enabling SMB volume services are here.
https://docs.pivotal.io/pivotalcf/2-4/opsguide/enable-vol-services.html#smb-enable
If you are a developer, the instructions for using it are here.
https://docs.pivotal.io/pivotalcf/2-4/devguide/services/using-vol-services.html#smb
If you are on an older version of PCF or your operator has not enabled this feature, then you would need to code something into your app to directly access your SMB volume. There are multiple libraries capable of doing this (and there could be more than in this list).
I can't recommend a particular one, so you'd need to evaluate and figure out which one works for you.
Do keep in mind that regardless of what you pick, you need to have network access to the SMB server from your application running on PCF. This means the IP needs to be routable and not blocked by a firewall. If you're unable to connect you may also want to review network access with your platform operator and make sure nothing is blocking the connection (firewall, application security groups, etc..).
Hope that helps!