flysystem
flysystem copied to clipboard
Get absolute path using Prefixer
Feature Request
Q | A |
---|---|
New Feature | yes |
BC Break | no |
Scenario / Use-case
Any time you want the full path to a file; perhaps a log or in my case to match a full path from configured regex like ~/path/to/file_\d{8}.ext~
:memo: Note I understand you I could simply keep track of the base path myself; but in my case that would require either decorating the library, or having 2 pieces of identical configuration which I fear could drift.
:memo: Note 2 Regarding just setting '/' always as the base path: sometimes this isn't possible. Some storage mechanisms may place you in a particular directory when you connect which is why defining a $root
is mandatory on some adapters (eg SFTP)
Summary
I understand that for portability reasons we do not want to enforce a Prefixer on all adapters (even though there are currently only 2 that do not use one: InMemory and FTP), but can we at least provide an interface and trait for this to give access to people who want to reference their files by it's instantiated path? It would make future adapters easier with composition and if someone wants to rely on the Prefixer's methods they could typehint the ancillary interface.
Hi @ash-m,
There is currently no way to do this within Flysystem without causing a major BC break (adding it to the interface) or going into extended interfaces with extra capabilities (FilesystemOperatorWithPathPrefixing), so I'm not overly excited to start supporting this. On the consuming side, it's possible to wrap your own use-cases with the combination of path prefixing and filesystem operations, which would remedy the problems you describe.