Hello and congrats for this great bundle.
I need to find the system path of the file. What's the best way to achieve this?
For now what I did is:
First I inject a File instance upon load with :
vich_uploader:
db_driver: orm
mappings:
data_files:
inject_on_load: true
Then in my controller, I use :
$file = $entity->getDocFile();
Is it the best approach?
Nop. And in fact, there is no "best approach" to your issue because it basically can't be achieved.
This bundle works with a local filesystem through the FileSystem storage engine but can also work with distant filesystems using either Gaufrette or Flysystem. And as retrieving "system paths" for distant filesystems can not be done, this bundle does not provide this functionality either.
How would I get the path relative to the storage system?
In my case I pass a reference to an object via a queue to another server. On the other server I want to do some post-processing to uploaded files. I already know which file-system I am using (in my case Gaufrette connecting to S3) but I need to know the directory and filename.
At the moment I am retrieving the file's URL and then stripping the uri_prefix, but surely this can't be the "right" way to do it.
The path relative to the filesystem is stored in the database so you can access it through your entity. (getImageName() in the example)
My bad, the directory isn't stored in the database. You might be able to access it using the storage service (vich_uploader.storage) and its resolvePath method.
The "vich_uploader.storage service not exist...
Why $downloadHandler has only downloadObject it should has getPath
Most helpful comment
The "vich_uploader.storage service not exist...
Why $downloadHandler has only downloadObject it should has getPath