Generating link to file

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

We have:

  • file - a resource in the file system.
    <file path="D:\sample\modules\web\web\VAADIN\images\myImage.jpg"/>

I tryed to insert my image, and when I look at GUI and copying link to this Image I’m getting something like
And it works))

Could I access the method, which generates this link?

Good news! =)

I think that you can use something lke:


    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.