PutFileIntoStorage with Path Name

Hi,

I ha tried saving file into local storage path by using fileStorageName but in some places fileupload path are present in database so due to this i am unable to set copy files to local path as storage name and path cannot be defined.
Is there any way we can define storage at runtime or store file on basis of path.

FileRef putFileIntoStorage(UUID fileId, String fileName, FileStorage fileStorage);

    FileRef putFileIntoStorage(UUID fileId, String fileName);

FileRef fileRef = null;
        try{
            FileStorage fileStorage = fileStorageLocator.getByName(fileStorageName);
            fileRef = temporaryStorage.putFileIntoStorage(fileUploader.getId(), fileName, fileStorage);
        }catch (Exception e){
            e.printStackTrace();
            return fileRef;
        }
        return fileRef;

Hi

If you want to have fileRef trees it may be better to use database entity relations as this is done in Jmix commertical WebDav addon, that you can also try to use for your purpose. FileStorages are oftenly backed to special store implementations like S3. Such implementations allows to specify hierrary in fileName, e.g. by setting it to “/folder/subfolder/filename.jpg”. As for using multiple storages, there is a documentation for that: Using File Storage :: Jmix Documentation

I also found workaround solution that looks like similar to your task: Переопределение пути к файлу fileStorageUpload - #3 от пользователя keanum75 - Вопросы и проблемы - Jmix

wbr, Aleksey