Skip to content

Commit

Permalink
Initial implementation of the WebDAV adapter.
Browse files Browse the repository at this point in the history
  • Loading branch information
frankdejonge committed Feb 14, 2022
1 parent 358506f commit 54ae1cf
Show file tree
Hide file tree
Showing 14 changed files with 642 additions and 9 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/src/AdapterTestUtilities export-ignore
/src/AzureBlobStorage export-ignore
/src/ZipArchive export-ignore
/src/WebDAV export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/bin/ export-ignore
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/quality-assurance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- .github/workflows/quality-assurance.yml
branches:
- 3.x
- 3.x-sabre
pull_request:
paths:
- src/**/*.php
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"google/cloud-storage": "^1.23",
"async-aws/s3": "^1.5",
"async-aws/simple-s3": "^1.0",
"sabre/dav": "^4.1"
"sabre/dav": "^4.3"
},
"conflict": {
"symfony/http-client": "<5.2",
Expand Down
10 changes: 9 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
---
version: "3"
services:
sabredav:
image: php:8.1-alpine3.15
restart: always
volumes:
- ./:/var/www/html/
ports:
- "4040:4040"
command: php -S 0.0.0.0:4040 /var/www/html/src/WebDAV/resources/server.php
webdav:
image: bytemark/webdav
restart: always
ports:
- "80:80"
- "4080:80"
environment:
AUTH_TYPE: Digest
USERNAME: alice
Expand Down
6 changes: 1 addition & 5 deletions src/AzureBlobStorage/AzureBlobStorageAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,7 @@ public function setVisibility(string $path, string $visibility): void

public function visibility(string $path): FileAttributes
{
try {
return $this->fetchMetadata($this->prefixer->prefixPath($path));
} catch (Throwable $exception) {
throw UnableToRetrieveMetadata::visibility($path, '', $exception);
}
throw UnableToRetrieveMetadata::visibility($path, 'Azure does not support visibility');
}

public function mimeType(string $path): FileAttributes
Expand Down
2 changes: 1 addition & 1 deletion src/DirectoryAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DirectoryAttributes implements StorageAttributes

public function __construct(string $path, ?string $visibility = null, ?int $lastModified = null, array $extraMetadata = [])
{
$this->path = $path;
$this->path = trim($path, '/');
$this->visibility = $visibility;
$this->lastModified = $lastModified;
$this->extraMetadata = $extraMetadata;
Expand Down
2 changes: 1 addition & 1 deletion src/FileAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(
?string $mimeType = null,
array $extraMetadata = []
) {
$this->path = $path;
$this->path = ltrim($path, '/');
$this->fileSize = $fileSize;
$this->visibility = $visibility;
$this->lastModified = $lastModified;
Expand Down
18 changes: 18 additions & 0 deletions src/WebDAV/ByteMarkWebDAVServerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace League\Flysystem\WebDAV;

use League\Flysystem\FilesystemAdapter;
use Sabre\DAV\Client;

class ByteMarkWebDAVServerTest extends WebDAVAdapterTestCase
{
protected static function createFilesystemAdapter(): FilesystemAdapter
{
$client = new Client(['baseUri' => 'http://localhost:4080/', 'userName' => 'alice', 'password' => 'secret1234']);

return new WebDAVAdapter($client, manualCopy: true, manualMove: true);
}
}
18 changes: 18 additions & 0 deletions src/WebDAV/SabreServerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace League\Flysystem\WebDAV;

use League\Flysystem\FilesystemAdapter;
use Sabre\DAV\Client;

class SabreServerTest extends WebDAVAdapterTestCase
{
protected static function createFilesystemAdapter(): FilesystemAdapter
{
$client = new Client(['baseUri' => 'http://localhost:4040/']);

return new WebDAVAdapter($client);
}
}
Loading

0 comments on commit 54ae1cf

Please sign in to comment.