Is there a way to have a permanent "hotlink" to an uploaded file

When uploading an image to via the file upload component, is there a way to create a permanent or predictable URL to the file/image?

For example here is a link to an image I uploaded via the component.
http://localhost:8080/app/APP/connector/0/2/view-657cbabc-8e57-42d4-9e3a-287986dec59f/image1.jpg

However, the link does not seem to permanent or predictable (via parameters or some other method)
I would like to link to the image from an external source, is this possible?

Hi Thomas,

There are two options to have a permanent link to an uploaded file: REST-API and a custom Spring controller.

You can use the first option if you require authentication from an external source. REST-API file downloading is described here: https://doc.cuba-platform.com/manual-6.3/rest_api_v2_ex_file_download.html

If you want to show images without any authentication then you have to create a custom Spring controller. At the moment it is not that simple task and requires a lot of manual work with internal CUBA API. I’ve created a small project that shows how to create such a custom download controller: https://github.com/cuba-labs/public-file-download There I use special PublicFile entity with a reference to FileDescriptor and export file content using special PublicFileDownloadController.

We are planning to improve API for FileStorage in one of the next versions of the platform where we will introduce simple API for obtaining a file stream from a middleware.

1 Like

Thanks for that answer. The REST API might work for my purposes. Glad to hear improvements are in the works.
Thanks again!

:ticket: See the following issue in our bug tracker:

https://youtrack.cuba-platform.com/issue/PL-8338