flysystem icon indicating copy to clipboard operation
flysystem copied to clipboard

Filesystem wrapper for a subfolder

Open hubertnnn opened this issue 2 years ago • 0 comments

Feature Request

Would be nice to have the ability to wrap an existing FlysystemOperator/Flysystem with a class that will point to a subfolder.

Q A
New Feature yes
BC Break no

Scenario / Use-case

I have a use case where my framework (Laravel) provides me a Flysystem object for a Disk and a third party library that expects a Flysystem object.

This works nice, but if I want to have multiple instances of that third party object I need to configure multiple disks in the framework. Instead would be nice if I could just take an existing disk and say "Create a new one that is located in a subfolder X"

Something like:

/** @var FlysystemOperator $flysystem */
$flysystem = Storage::disk('foo')->getDriver();

foreach($instances as $instance) {
    $library = new Library($instance, new FlysystemWrapper($flysystem, $instance . '/'));
    $library->doSomething();
}

hubertnnn avatar Apr 26 '22 09:04 hubertnnn