Manage file storage folders

Hi,
I have a question about best way to manage folders in file storage.
Actually when I upload and save (fileStorage.saveStream()) a file into store it is organized by year/mont. I would like to save file in another three logic not by date but by another dimension, so i would like to save it inside a folder depends of customer for example.
My actual folders three is:
store/2023/12/n-files and it works by default in this way but I would like to save files in store/customerA/n-files, choosing the costumer folder at the moment of the saving action.

Thanks

Hi,

You may try creating your own FileStorage implementation looking at the io.jmix.localfs.LocalFileStorage as an example.

The io.jmix.core.FileStorage#saveStream(java.lang.String, java.io.InputStream, java.util.Map<java.lang.String,java.lang.Object>) method accepts the parameters map. In this map you may pass the customer information and then select the folder based on this.

You may make your FileStorage implementation a default one.

1 Like