I have two entities where uploading of file is available. Files uploaded for one entity will be deleted regularly whereas for other entity they will remain forever.
How can I save files uploaded from each entity to separate folder. This will make easier for deletion of files (I will just delete folder content on server). If there is any other ways to fulfill this requirement.
However interface of FileStorageAPI doesn’t know anything about entity owning the FileDescriptor. So you would need to invent some hacks to distinguish owning entities.
I think it will be easier for you to find required files for cleaning by making SQL request and joining owning entity with file descriptors:
select f.* from sys_file f join my_entity e where e.file_id = f.id