feat(storage): 新增WebDAV存储驱动

This commit is contained in:
augushong
2026-08-20 22:13:15 +08:00
parent 5cdfac0333
commit f76f832307

View File

@@ -0,0 +1,27 @@
<?php
namespace think\filesystem\driver;
use League\Flysystem\FilesystemAdapter;
use League\Flysystem\WebDAV\WebDAVAdapter;
use Sabre\DAV\Client;
use think\filesystem\Driver;
class Webdav extends Driver
{
protected function createAdapter(): FilesystemAdapter
{
$client = new Client([
'baseUri' => sysconfig('upload', 'webdav_url'),
'userName' => sysconfig('upload', 'webdav_username'),
'password' => sysconfig('upload', 'webdav_password'),
]);
return new WebDAVAdapter($client, sysconfig('upload', 'webdav_prefix', ''));
}
public function url(string $path): string
{
return $this->concatPathToUrl(sysconfig('upload', 'webdav_domain'), $path);
}
}