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\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);

@ -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)) {

@ -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);

@ -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"
},

@ -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,
],

@ -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"
},