laravel-webdav
laravel-webdav copied to clipboard
list files: empty result and/or Sabre Exception
I have a webdav folder containing:
- <my webdav location>
readme.md
- testfolder
readme.md
When listing files in root directory:
Storage::disk('webdav')->files() // Sabre\HTTP\ClientHttpException with message 'Method Not Allowed'
Storage::disk('webdav')->files('/') // Sabre\HTTP\ClientHttpException with message 'Method Not Allowed'
When listing specific file or folder I get an empty result:
Storage::disk('webdav')->files('Readme.md') // []
Storage::disk('webdav')->files('testfolder') // []
Storage::disk('webdav')->files('testfolder/') // []
Correct / expected behavior when listing non-existing file/folder:
Storage::disk('webdav')->files('doesnotexist') // correct: Sabre\HTTP\ClientHttpException with message 'Not Found'
Correct / expected behavior when using local filesystem:
Storage::disk('local')->files()
=> [
".gitignore",
]
(using WEBDAV_URI
with trailing /
, see #9)
Manual curl
examples works fine:
curl -X PROPFIND --user "$WEBDAV_TOKEN:" "$WEBDAV_URI"
curl -X PROPFIND --user "$WEBDAV_TOKEN:" "$WEBDAV_URI/Readme.md"
curl -X PROPFIND --user "$WEBDAV_TOKEN:" "$WEBDAV_URI/testfolder"
e.g.
<?xml version="1.0"?>
<d:multistatus xmlns:d="DAV:"
xmlns:s="http://sabredav.org/ns"
xmlns:oc="http://owncloud.org/ns"
xmlns:nc="http://nextcloud.org/ns">
<d:response>
<d:href>/public.php/webdav/testfolder/</d:href>
<d:propstat>
<d:prop>
<d:getlastmodified>Fri, 08 Jan 2021 14:15:11 GMT</d:getlastmodified>
<d:resourcetype>
<d:collection/>
</d:resourcetype>
<d:quota-used-bytes>6</d:quota-used-bytes>
<d:quota-available-bytes>-3</d:quota-available-bytes>
<d:getetag>"5f37wf868fehjekhef1cfh210"</d:getetag>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
</d:response>
<d:response>
<d:href>/public.php/webdav/testfolder/Readme.md</d:href>
<d:propstat>
<d:prop>
<d:getlastmodified>Fri, 08 Jan 2021 14:15:11 GMT</d:getlastmodified>
<d:getcontentlength>6</d:getcontentlength>
<d:resourcetype/>
<d:getetag>"ea8e2f6d3h2fjefeg87b54cb7998dd58da"</d:getetag>
<d:getcontenttype>text/markdown</d:getcontenttype>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
<d:propstat>
<d:prop>
<d:quota-used-bytes/>
<d:quota-available-bytes/>
</d:prop>
<d:status>HTTP/1.1 404 Not Found</d:status>
</d:propstat>
</d:response>
</d:multistatus>
Hello, try this:
'webdav' => [
'driver' => 'webdav',
'baseUri' => 'https://nextcloud.com/',
'userName' => 'UserXXX',
'password' => '******',
'pathPrefix' => 'remote.php/dav/files/UserXXX/',
],
And then write
Storage::disk('webdav')->allFiles('/')
I see, so I have to split the path. (in my case I am using shared folder, with token)
works:
'webdav' => [
'driver' => 'webdav',
'baseUri' => 'https://mynextcloud.com/',
'userName' => 'tokenXXX',
'pathPrefix' => 'public.php/webdav/',
],
works for get()
and put()
but not for files()
:
'webdav' => [
'driver' => 'webdav',
'baseUri' => 'https://mynextcloud.com/public.php/webdav/',
'userName' => 'tokenXXX',
],