feat(dav): Enable chunked upload for public shares

Signed-off-by: provokateurin <kate@provokateurin.de>
pull/52182/head
provokateurin 2025-04-14 15:41:13 +07:00
parent a55e61d97c
commit 46f5b07322
No known key found for this signature in database
6 changed files with 32 additions and 3 deletions

@ -14,12 +14,15 @@ use OCA\DAV\Files\Sharing\FilesDropPlugin;
use OCA\DAV\Files\Sharing\PublicLinkCheckPlugin; use OCA\DAV\Files\Sharing\PublicLinkCheckPlugin;
use OCA\DAV\Storage\PublicOwnerWrapper; use OCA\DAV\Storage\PublicOwnerWrapper;
use OCA\DAV\Storage\PublicShareWrapper; use OCA\DAV\Storage\PublicShareWrapper;
use OCA\DAV\Upload\ChunkingPlugin;
use OCA\DAV\Upload\ChunkingV2Plugin;
use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\FederatedFileSharing\FederatedShareProvider;
use OCP\BeforeSabrePubliclyLoadedEvent; use OCP\BeforeSabrePubliclyLoadedEvent;
use OCP\Constants; use OCP\Constants;
use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder; use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountManager; use OCP\Files\Mount\IMountManager;
use OCP\ICacheFactory;
use OCP\IConfig; use OCP\IConfig;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\IPreview; use OCP\IPreview;
@ -138,6 +141,8 @@ $server = $serverFactory->createServer(true, $baseuri, $requestUri, $authPlugin,
$server->addPlugin($linkCheckPlugin); $server->addPlugin($linkCheckPlugin);
$server->addPlugin($filesDropPlugin); $server->addPlugin($filesDropPlugin);
$server->addPlugin(new ChunkingV2Plugin(Server::get(ICacheFactory::class)));
$server->addPlugin(new ChunkingPlugin());
// allow setup of additional plugins // allow setup of additional plugins
$event = new BeforeSabrePubliclyLoadedEvent($server); $event = new BeforeSabrePubliclyLoadedEvent($server);

@ -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() { public function getCapabilities() {
$capabilities = [ $capabilities = [
'dav' => [ 'dav' => [
'chunking' => '1.0', 'chunking' => '1.0',
'public_shares_chunking' => true,
] ]
]; ];
if ($this->config->getSystemValueBool('bulkupload.enabled', true)) { if ($this->config->getSystemValueBool('bulkupload.enabled', true)) {

@ -15,6 +15,7 @@ use OCA\DAV\CalDAV\Proxy\ProxyMapper;
use OCA\DAV\DAV\CustomPropertiesBackend; use OCA\DAV\DAV\CustomPropertiesBackend;
use OCA\DAV\DAV\ViewOnlyPlugin; use OCA\DAV\DAV\ViewOnlyPlugin;
use OCA\DAV\Files\BrowserErrorPagePlugin; use OCA\DAV\Files\BrowserErrorPagePlugin;
use OCA\DAV\Upload\CleanupService;
use OCA\Theming\ThemingDefaults; use OCA\Theming\ThemingDefaults;
use OCP\Accounts\IAccountManager; use OCP\Accounts\IAccountManager;
use OCP\App\IAppManager; use OCP\App\IAppManager;
@ -22,6 +23,7 @@ use OCP\Comments\ICommentsManager;
use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Folder; use OCP\Files\Folder;
use OCP\Files\IFilenameValidator; use OCP\Files\IFilenameValidator;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountManager; use OCP\Files\Mount\IMountManager;
use OCP\IConfig; use OCP\IConfig;
use OCP\IDBConnection; use OCP\IDBConnection;
@ -153,6 +155,16 @@ class ServerFactory {
$userPrincipalBackend, $userPrincipalBackend,
'principals/shares', '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 { } else {
/** @var ObjectTree $tree */ /** @var ObjectTree $tree */
$tree->init($root, $view, $this->mountManager); $tree->init($root, $view, $this->mountManager);

@ -29,12 +29,16 @@
"dav": { "dav": {
"type": "object", "type": "object",
"required": [ "required": [
"chunking" "chunking",
"public_shares_chunking"
], ],
"properties": { "properties": {
"chunking": { "chunking": {
"type": "string" "type": "string"
}, },
"public_shares_chunking": {
"type": "boolean"
},
"bulkupload": { "bulkupload": {
"type": "string" "type": "string"
}, },

@ -28,6 +28,7 @@ class CapabilitiesTest extends TestCase {
$expected = [ $expected = [
'dav' => [ 'dav' => [
'chunking' => '1.0', 'chunking' => '1.0',
'public_shares_chunking' => true,
], ],
]; ];
$this->assertSame($expected, $capabilities->getCapabilities()); $this->assertSame($expected, $capabilities->getCapabilities());
@ -47,6 +48,7 @@ class CapabilitiesTest extends TestCase {
$expected = [ $expected = [
'dav' => [ 'dav' => [
'chunking' => '1.0', 'chunking' => '1.0',
'public_shares_chunking' => true,
'bulkupload' => '1.0', 'bulkupload' => '1.0',
], ],
]; ];
@ -67,6 +69,7 @@ class CapabilitiesTest extends TestCase {
$expected = [ $expected = [
'dav' => [ 'dav' => [
'chunking' => '1.0', 'chunking' => '1.0',
'public_shares_chunking' => true,
'absence-supported' => true, 'absence-supported' => true,
'absence-replacement' => true, 'absence-replacement' => true,
], ],

@ -1480,12 +1480,16 @@
"dav": { "dav": {
"type": "object", "type": "object",
"required": [ "required": [
"chunking" "chunking",
"public_shares_chunking"
], ],
"properties": { "properties": {
"chunking": { "chunking": {
"type": "string" "type": "string"
}, },
"public_shares_chunking": {
"type": "boolean"
},
"bulkupload": { "bulkupload": {
"type": "string" "type": "string"
}, },