Nextcloud ok save doc
This commit is contained in:
@@ -129,7 +129,7 @@ class StorageRepositoryService
|
||||
return $config;
|
||||
}
|
||||
|
||||
private function normalizePath(string $path): string
|
||||
public function normalizePath(string $path): string
|
||||
{
|
||||
$path = trim($path);
|
||||
if ($path === '' || $path === '\\') {
|
||||
@@ -148,6 +148,15 @@ class StorageRepositoryService
|
||||
|
||||
private function buildWebDAV(array $config): ?Filesystem
|
||||
{
|
||||
$fullBaseUri = rtrim($config['base_uri'] ?? '', '/') . '/';
|
||||
|
||||
$parsedUrl = parse_url($fullBaseUri);
|
||||
$schemeHost = ($parsedUrl['scheme'] ?? 'https') . '://' . ($parsedUrl['host'] ?? 'localhost');
|
||||
$basePath = rawurldecode($parsedUrl['path'] ?? '/');
|
||||
|
||||
$root = '/' . trim($config['root'] ?? '/', '/') . '/';
|
||||
$prefix = rtrim($basePath, '/') . $root;
|
||||
|
||||
$authType = match ($config['auth_type'] ?? 'basic') {
|
||||
'basic' => WebDAVClient::AUTH_BASIC,
|
||||
'digest' => WebDAVClient::AUTH_DIGEST,
|
||||
@@ -156,14 +165,13 @@ class StorageRepositoryService
|
||||
};
|
||||
|
||||
$client = new WebDAVClient([
|
||||
'baseUri' => rtrim($config['base_uri'] ?? '', '/') . '/',
|
||||
'baseUri' => $schemeHost . '/',
|
||||
'userName' => $config['username'] ?? '',
|
||||
'password' => $config['password'] ?? '',
|
||||
'authType' => $authType,
|
||||
]);
|
||||
|
||||
$root = ltrim($config['root'] ?? '/', '/');
|
||||
$adapter = new WebDAVAdapter($client, $root);
|
||||
$adapter = new WebDAVAdapter($client, $prefix);
|
||||
|
||||
return new Filesystem($adapter);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user