phplaravelwebdavflysystem

How to get the list of files in the WEBDAV directory with Flysystem?


I found similar question on stackoverflow but noone answered there.

So I'am trying to get the list of files from the WEBDAV cloud storage using laravel-flysystem framework that is based on Flysystem. I did everything according to manual and everything is working perfectly except one function - listContents().

Here is an example of my code

var_dump(Flysystem::read('/test/test.txt'));
var_dump(Flysystem::listContents('/test/'));

This code returns the following:

string(4) "123"
array(0) {
}

I have test.txt file in the test/ directory and read() function return's it's content but listContents() function don't return the file.

Can someone please explain what can be done to get the list of files from the directory? Thanks.


Solution

  • So for now as a temporary solution I had to change the code in vendor. An awful decision but I don't plan to use composer in this project for the time and just for reinsurance I locked the version of league/flysystem in composer.json

    So as a solution I went to vendor/league/flysystem/src/Util/ContentListingFormatter.php (it exist in 1.0.57 version of league/flysystem for shure). In function isDirectChild() you need to return true; . This way you will get an array of actual files from your webdav directory instead of an empty array.

    I really hope that this bug will be fixed someday.