Skip to content

Commit fbcfa89

Browse files
committed
feat(dav): Enable chunked upload for public shares
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent 577e6aa commit fbcfa89

5 files changed

Lines changed: 28 additions & 2 deletions

File tree

apps/dav/appinfo/v1/publicwebdav.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@
1313
use OCA\DAV\Files\Sharing\FilesDropPlugin;
1414
use OCA\DAV\Files\Sharing\PublicLinkCheckPlugin;
1515
use OCA\DAV\Storage\PublicOwnerWrapper;
16+
use OCA\DAV\Upload\ChunkingPlugin;
17+
use OCA\DAV\Upload\ChunkingV2Plugin;
1618
use OCA\FederatedFileSharing\FederatedShareProvider;
1719
use OCP\BeforeSabrePubliclyLoadedEvent;
1820
use OCP\Constants;
1921
use OCP\EventDispatcher\IEventDispatcher;
2022
use OCP\Files\IRootFolder;
2123
use OCP\Files\Mount\IMountManager;
24+
use OCP\ICacheFactory;
2225
use OCP\IConfig;
2326
use OCP\IDBConnection;
2427
use OCP\IPreview;
@@ -114,6 +117,8 @@
114117

115118
$server->addPlugin($linkCheckPlugin);
116119
$server->addPlugin($filesDropPlugin);
120+
$server->addPlugin(new ChunkingV2Plugin(Server::get(ICacheFactory::class)));
121+
$server->addPlugin(new ChunkingPlugin());
117122
// allow setup of additional plugins
118123
$event = new BeforeSabrePubliclyLoadedEvent($server);
119124
$eventDispatcher->dispatchTyped($event);

apps/dav/appinfo/v2/publicremote.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
use OCA\DAV\Files\Sharing\PublicLinkCheckPlugin;
1515
use OCA\DAV\Storage\PublicOwnerWrapper;
1616
use OCA\DAV\Storage\PublicShareWrapper;
17+
use OCA\DAV\Upload\ChunkingPlugin;
18+
use OCA\DAV\Upload\ChunkingV2Plugin;
1719
use OCA\FederatedFileSharing\FederatedShareProvider;
1820
use OCP\BeforeSabrePubliclyLoadedEvent;
1921
use OCP\Constants;
2022
use OCP\EventDispatcher\IEventDispatcher;
2123
use OCP\Files\IRootFolder;
2224
use OCP\Files\Mount\IMountManager;
25+
use OCP\ICacheFactory;
2326
use OCP\IConfig;
2427
use OCP\IDBConnection;
2528
use OCP\IPreview;
@@ -138,6 +141,8 @@
138141

139142
$server->addPlugin($linkCheckPlugin);
140143
$server->addPlugin($filesDropPlugin);
144+
$server->addPlugin(new ChunkingV2Plugin(Server::get(ICacheFactory::class)));
145+
$server->addPlugin(new ChunkingPlugin());
141146

142147
// allow setup of additional plugins
143148
$event = new BeforeSabrePubliclyLoadedEvent($server);

apps/dav/lib/Capabilities.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ public function __construct(
1717
}
1818

1919
/**
20-
* @return array{dav: array{chunking: string, bulkupload?: string, absence-supported?: bool, absence-replacement?: bool}}
20+
* @return array{dav: array{chunking: string, public-shares-chunking: bool, bulkupload?: string, absence-supported?: bool, absence-replacement?: bool}}
2121
*/
2222
public function getCapabilities() {
2323
$capabilities = [
2424
'dav' => [
2525
'chunking' => '1.0',
26+
'public-shares-chunking' => true,
2627
]
2728
];
2829
if ($this->config->getSystemValueBool('bulkupload.enabled', true)) {

apps/dav/lib/Connector/Sabre/ServerFactory.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
use OCA\DAV\DAV\CustomPropertiesBackend;
1616
use OCA\DAV\DAV\ViewOnlyPlugin;
1717
use OCA\DAV\Files\BrowserErrorPagePlugin;
18+
use OCA\DAV\Upload\CleanupService;
1819
use OCA\Theming\ThemingDefaults;
1920
use OCP\Accounts\IAccountManager;
2021
use OCP\App\IAppManager;
2122
use OCP\Comments\ICommentsManager;
2223
use OCP\EventDispatcher\IEventDispatcher;
2324
use OCP\Files\Folder;
2425
use OCP\Files\IFilenameValidator;
26+
use OCP\Files\IRootFolder;
2527
use OCP\Files\Mount\IMountManager;
2628
use OCP\IConfig;
2729
use OCP\IDBConnection;
@@ -147,6 +149,15 @@ public function createServer(
147149
'principals/shares',
148150
));
149151

152+
$rootCollection->addChild(new \OCA\DAV\Upload\RootCollection(
153+
$userPrincipalBackend,
154+
'principals/shares',
155+
\OCP\Server::get(CleanupService::class),
156+
\OCP\Server::get(IRootFolder::class),
157+
\OCP\Server::get(IUserSession::class),
158+
\OCP\Server::get(\OCP\Share\IManager::class),
159+
));
160+
150161
$server->addPlugin(
151162
new FilesPlugin(
152163
$tree,

apps/dav/openapi.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@
2929
"dav": {
3030
"type": "object",
3131
"required": [
32-
"chunking"
32+
"chunking",
33+
"public-shares-chunking"
3334
],
3435
"properties": {
3536
"chunking": {
3637
"type": "string"
3738
},
39+
"public-shares-chunking": {
40+
"type": "boolean"
41+
},
3842
"bulkupload": {
3943
"type": "string"
4044
},

0 commit comments

Comments
 (0)