diff options
author | provokateurin <kate@provokateurin.de> | 2025-04-14 15:41:13 +0200 |
---|---|---|
committer | provokateurin <kate@provokateurin.de> | 2025-05-05 13:23:11 +0200 |
commit | 46f5b07322330c0a93d8c6c83eaf85a03b7173b1 (patch) | |
tree | a40e13c0627a6298fcee2dcb658bb0650d5a7eaf | |
parent | a55e61d97c09b80afb4748edacdb14966710d300 (diff) | |
download | nextcloud-server-46f5b07322330c0a93d8c6c83eaf85a03b7173b1.tar.gz nextcloud-server-46f5b07322330c0a93d8c6c83eaf85a03b7173b1.zip |
feat(dav): Enable chunked upload for public shares
Signed-off-by: provokateurin <kate@provokateurin.de>
-rw-r--r-- | apps/dav/appinfo/v2/publicremote.php | 5 | ||||
-rw-r--r-- | apps/dav/lib/Capabilities.php | 3 | ||||
-rw-r--r-- | apps/dav/lib/Connector/Sabre/ServerFactory.php | 12 | ||||
-rw-r--r-- | apps/dav/openapi.json | 6 | ||||
-rw-r--r-- | apps/dav/tests/unit/CapabilitiesTest.php | 3 | ||||
-rw-r--r-- | openapi.json | 6 |
6 files changed, 32 insertions, 3 deletions
diff --git a/apps/dav/appinfo/v2/publicremote.php b/apps/dav/appinfo/v2/publicremote.php index b1074f33115..62336a9b80f 100644 --- a/apps/dav/appinfo/v2/publicremote.php +++ b/apps/dav/appinfo/v2/publicremote.php @@ -14,12 +14,15 @@ use OCA\DAV\Files\Sharing\FilesDropPlugin; use OCA\DAV\Files\Sharing\PublicLinkCheckPlugin; use OCA\DAV\Storage\PublicOwnerWrapper; use OCA\DAV\Storage\PublicShareWrapper; +use OCA\DAV\Upload\ChunkingPlugin; +use OCA\DAV\Upload\ChunkingV2Plugin; use OCA\FederatedFileSharing\FederatedShareProvider; use OCP\BeforeSabrePubliclyLoadedEvent; use OCP\Constants; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountManager; +use OCP\ICacheFactory; use OCP\IConfig; use OCP\IDBConnection; use OCP\IPreview; @@ -138,6 +141,8 @@ $server = $serverFactory->createServer(true, $baseuri, $requestUri, $authPlugin, $server->addPlugin($linkCheckPlugin); $server->addPlugin($filesDropPlugin); +$server->addPlugin(new ChunkingV2Plugin(Server::get(ICacheFactory::class))); +$server->addPlugin(new ChunkingPlugin()); // allow setup of additional plugins $event = new BeforeSabrePubliclyLoadedEvent($server); diff --git a/apps/dav/lib/Capabilities.php b/apps/dav/lib/Capabilities.php index ab4e53fce37..f321222b285 100644 --- a/apps/dav/lib/Capabilities.php +++ b/apps/dav/lib/Capabilities.php @@ -17,12 +17,13 @@ class Capabilities implements ICapability { } /** - * @return array{dav: array{chunking: string, bulkupload?: string, absence-supported?: bool, absence-replacement?: bool}} + * @return array{dav: array{chunking: string, public_shares_chunking: bool, bulkupload?: string, absence-supported?: bool, absence-replacement?: bool}} */ public function getCapabilities() { $capabilities = [ 'dav' => [ 'chunking' => '1.0', + 'public_shares_chunking' => true, ] ]; if ($this->config->getSystemValueBool('bulkupload.enabled', true)) { diff --git a/apps/dav/lib/Connector/Sabre/ServerFactory.php b/apps/dav/lib/Connector/Sabre/ServerFactory.php index 6c00fecea8d..bdd13b7f44e 100644 --- a/apps/dav/lib/Connector/Sabre/ServerFactory.php +++ b/apps/dav/lib/Connector/Sabre/ServerFactory.php @@ -15,6 +15,7 @@ use OCA\DAV\CalDAV\Proxy\ProxyMapper; use OCA\DAV\DAV\CustomPropertiesBackend; use OCA\DAV\DAV\ViewOnlyPlugin; use OCA\DAV\Files\BrowserErrorPagePlugin; +use OCA\DAV\Upload\CleanupService; use OCA\Theming\ThemingDefaults; use OCP\Accounts\IAccountManager; use OCP\App\IAppManager; @@ -22,6 +23,7 @@ use OCP\Comments\ICommentsManager; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Folder; use OCP\Files\IFilenameValidator; +use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountManager; use OCP\IConfig; use OCP\IDBConnection; @@ -153,6 +155,16 @@ class ServerFactory { $userPrincipalBackend, 'principals/shares', )); + + // Mount the upload collection at /public.php/dav/uploads/<share token> + $rootCollection->addChild(new \OCA\DAV\Upload\RootCollection( + $userPrincipalBackend, + 'principals/shares', + \OCP\Server::get(CleanupService::class), + \OCP\Server::get(IRootFolder::class), + \OCP\Server::get(IUserSession::class), + \OCP\Server::get(\OCP\Share\IManager::class), + )); } else { /** @var ObjectTree $tree */ $tree->init($root, $view, $this->mountManager); diff --git a/apps/dav/openapi.json b/apps/dav/openapi.json index 449ae09dff1..48d6ae03ee0 100644 --- a/apps/dav/openapi.json +++ b/apps/dav/openapi.json @@ -29,12 +29,16 @@ "dav": { "type": "object", "required": [ - "chunking" + "chunking", + "public_shares_chunking" ], "properties": { "chunking": { "type": "string" }, + "public_shares_chunking": { + "type": "boolean" + }, "bulkupload": { "type": "string" }, diff --git a/apps/dav/tests/unit/CapabilitiesTest.php b/apps/dav/tests/unit/CapabilitiesTest.php index e99f7b8da5f..21d00ef183f 100644 --- a/apps/dav/tests/unit/CapabilitiesTest.php +++ b/apps/dav/tests/unit/CapabilitiesTest.php @@ -28,6 +28,7 @@ class CapabilitiesTest extends TestCase { $expected = [ 'dav' => [ 'chunking' => '1.0', + 'public_shares_chunking' => true, ], ]; $this->assertSame($expected, $capabilities->getCapabilities()); @@ -47,6 +48,7 @@ class CapabilitiesTest extends TestCase { $expected = [ 'dav' => [ 'chunking' => '1.0', + 'public_shares_chunking' => true, 'bulkupload' => '1.0', ], ]; @@ -67,6 +69,7 @@ class CapabilitiesTest extends TestCase { $expected = [ 'dav' => [ 'chunking' => '1.0', + 'public_shares_chunking' => true, 'absence-supported' => true, 'absence-replacement' => true, ], diff --git a/openapi.json b/openapi.json index d68377fcaa8..61db0fbc652 100644 --- a/openapi.json +++ b/openapi.json @@ -1480,12 +1480,16 @@ "dav": { "type": "object", "required": [ - "chunking" + "chunking", + "public_shares_chunking" ], "properties": { "chunking": { "type": "string" }, + "public_shares_chunking": { + "type": "boolean" + }, "bulkupload": { "type": "string" }, |