VichUploaderBundle
VichUploaderBundle copied to clipboard
absolute path on File rather than Relative
BC Break Report
Q | A |
---|---|
BC Break | yes |
Version | 1.10.2 |
Summary
Considering this entity mapping
/**
* @Assert\NotBlank()
* @Vich\UploadableField(mapping="assets", fileNameProperty="filename")
*/
private $file;
Previous behavior
in version 1.10.1
$profilePhoto->getFile()->getPathname()
will return a relative path like photos/123456.jpg
Current behavior
in version 1.10.2
$profilePhoto->getFile()->getPathname()
will return an absolute path like /var/www/html/example.com/public_html/photos/123456.jpg
How to reproduce
- dump the contents of a "file", note the path variables
- update vich uploader bundle
- dump the contents of a "file", note the path variables
I am using Flysytem with both a local and S3 adaptor depending on the dev or prod environment.
I suspect maybe the change in Storage/FlysystemStorage.php is the culprit
yes, reverting that single change returns the previous behaviour. Why the change? How else would I go about getting the relative file path?
See discussion in #493
fair enough, so the expected behaviour is to receive an absolute path then. What is the best way to get the relative path? or do I just hard code it?
You should know the path of your assets, since you configured it. Just retrieve such path from configuration
Hi everyone !
Another problem is that the method applyPathPrefix()
is not registred on the interface AdapterInterface.php.
So, when you use the MemoryAdapter
from Flysystem, you got an error :
Call to undefined method League\Flysystem\Memory\MemoryAdapter::applyPathPrefix()
#1 /builds/xxxx/vendor/vich/uploader-bundle/Storage/FlysystemStorage.php:64
I summon @leigh-ols (being the auhor of PR that closed related issue)
Ah,... that's a difficult one.
I have to be honest i'm not particularly familiar with either of the two code bases, so I'm far from an authority.
What we had before didn't work at all, so although PR #1007 is apparently not perfect, it's still an improvement on what we had.
Does anyone have any ideas on how to get the absolute path in a manner that sticks religiously to the interfaces of Flysystem?