Hello!
I need to generate an external link to file to access through the CUBA sysytem and return it in the restAPI response.
I have file in my file storage on disk.
There is no FileDescriptor links to this file in the table sys_file.
For example I have a file in the folder /home/files/image.jpg
I have tryed the FileUploadingAPI and FileStorageService, but I didn’t find anything.
Hi there!
Take a look at:
@arimolo thank’s a lot!! Very nice solution, I will use it.
But I have another question.
There is in the docs under link https://doc.cuba-platform.com/manual-latest/gui_Image.html
We have:
-
file
- a resource in the file system.
<image>
<file path="D:\sample\modules\web\web\VAADIN\images\myImage.jpg"/>
</image>
I tryed to insert my image, and when I look at GUI and copying link to this Image I’m getting something like
http://localhost:8080/app/APP/connector/0/103/source/myImage.jpg
And it works))
Could I access the method, which generates this link?
Good news! =)
I think that you can use something lke:
Inject:
private GlobalConfig globalConfig;
Then use like:
String imgUrl = globalConfig.getWebAppUrl() + " /APP/connector/0/103/source/" + getImageName();
And is the line /APP/connector/0/103/source/
shoud be a hardcoded?
I think so, with controller’s path. Sure you can define a constant.