Hi there,
I am still new to CUBA. Could you help me out with an idea…
I am trying to download an Image directly from FTP server using apache commons net library. I don’t want to save image to temp folder or database. How can I make userImage (image) field load the picture from a stream?
protected void postInit() {
super.postInit();
FTPClient ftpClient = new FTPClient();
try{
ftpClient.connect(FTP_SERVER);
ftpClient.login(FTP_USERNAME, FTP_PASSWORD);
// File file = new File("/modules/web/themes/halo/test.jpeg"); //used for testing
try(FileOutputStream fos = new FileOutputStream(file)){
ftpClient.retrieveFile(FTP_IMAGE, fos);
// userImage.setSource(StreamResource.class).getStreamSupplier(?????);
}
} catch (IOException io){
io.printStackTrace();
}
);
The other option I thought about is using CUBA functionality and load the files from temp folder. The problem there is that temp folder is in “deploy/tomcat/temp/app/” and when I try to deploy the application to a dev server I cannot specify a folder there. On localhost it is working, but deployed somewhere else - not.
Thank you in advance!