Open
Description
If using StoreAsPath
and all your filename prefixes are the same (ie some/dir/filename.ext
) it can be a waste of resources to store the same prefix in the db over and over.
I propose a StoreAsFilename
mapping:
#[StoreAsFilename(
filesystem: 'public'
fileNamer: new Expression('{this.title|slug}-{name}{ext}'), // would throw an exception if contains /'s
directoryNamer: new Expression('some/dir'),
)]
private File $file;
When saving to db, just the filename would be stored. When loading, the directoryNamer
would be used to create the prefix and append the filename to it.
As a slight perf boost, we could add a String
Namer that doesn't require processing and just returns the string. Probably a SelfGeneratingNamer
concept should be added.
#[StoreAsFilename(
filesystem: 'public'
fileNamer: new Expression('{this.title|slug}-{name}{ext}'),
directoryNamer: new String('some/dir'),
)]
private File $file;