Enonic version: 6.8.1
OS: Centos 6.7
We have a requirement where we need to connect to ftp and read data from a file.
I am able to down the file from “wget” command on server but how to use it so that Enonic XP can read it.
How can I refer that file in my code (controller)?
Do I understand you correctly that you have been able to “download” the file from FTP into your server that XP runs on?
Then try the IO lib in XP to read that file:
I am able to download the file, but how to let the Enonic XP know the location of file (whether It can read the files from server or does the file needs to be in file system(blobs))?
Most of the io functions has a stream as input parameter.
The only one I can find which takes a path is the getResource which looks inside the JAR file, not the file system.
So we need some method to read from the file system and return a stream.
Perhaps the code surrounding reading xp config files runtime could be used as a workaround?
Aka placing the file in the config folder?
I’m guessing reading files from the file-system is sorta a security risk.
Can any one pls help for this issue ?
Best way is probably to create a small java tool/lib that reads the file from disk if you need to serve the file from outside your application, then get the byteSource from the lib.
If its a small file that you should fetch more than one time, aro’s suggestion is the way to go.
I don’t know how you are executing the wget command, but you could also use the same wget command to post the file downloaded to a service controller in the app. And read the data in the service controller, with a post handler function. The
body property of the request should contain the data.