Skip to content

Commit bb6fc88

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

6 files changed

Lines changed: 31 additions & 3 deletions

File tree

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;
@@ -153,6 +155,15 @@ public function createServer(
153155
$userPrincipalBackend,
154156
'principals/shares',
155157
));
158+
159+
$rootCollection->addChild(new \OCA\DAV\Upload\RootCollection(
160+
$userPrincipalBackend,
161+
'principals/shares',
162+
\OCP\Server::get(CleanupService::class),
163+
\OCP\Server::get(IRootFolder::class),
164+
\OCP\Server::get(IUserSession::class),
165+
\OCP\Server::get(\OCP\Share\IManager::class),
166+
));
156167
} else {
157168
/** @var ObjectTree $tree */
158169
$tree->init($root, $view, $this->mountManager);

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

apps/dav/tests/unit/CapabilitiesTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function testGetCapabilities(): void {
2828
$expected = [
2929
'dav' => [
3030
'chunking' => '1.0',
31+
'public_shares_chunking' => true,
3132
],
3233
];
3334
$this->assertSame($expected, $capabilities->getCapabilities());
@@ -47,6 +48,7 @@ public function testGetCapabilitiesWithBulkUpload(): void {
4748
$expected = [
4849
'dav' => [
4950
'chunking' => '1.0',
51+
'public_shares_chunking' => true,
5052
'bulkupload' => '1.0',
5153
],
5254
];
@@ -67,6 +69,7 @@ public function testGetCapabilitiesWithAbsence(): void {
6769
$expected = [
6870
'dav' => [
6971
'chunking' => '1.0',
72+
'public_shares_chunking' => true,
7073
'absence-supported' => true,
7174
'absence-replacement' => true,
7275
],

openapi.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,12 +1382,16 @@
13821382
"dav": {
13831383
"type": "object",
13841384
"required": [
1385-
"chunking"
1385+
"chunking",
1386+
"public_shares_chunking"
13861387
],
13871388
"properties": {
13881389
"chunking": {
13891390
"type": "string"
13901391
},
1392+
"public_shares_chunking": {
1393+
"type": "boolean"
1394+
},
13911395
"bulkupload": {
13921396
"type": "string"
13931397
},

0 commit comments

Comments
 (0)