mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-08-30 12:45:32 +08:00
feat(storage): 新增WebDAV存储驱动
This commit is contained in:
27
extend/think/filesystem/driver/Webdav.php
Normal file
27
extend/think/filesystem/driver/Webdav.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user