@@ -25,6 +25,7 @@ import { Directory } from '../utils/fileTree.ts'
2525import { t } from '../utils/l10n.ts'
2626import logger from '../utils/logger.ts'
2727import { Eta } from './eta.ts'
28+ import { generateRemoteUrl , getBaseUrl } from '@nextcloud/router'
2829
2930export enum UploaderStatus {
3031 IDLE = 0 ,
@@ -477,7 +478,7 @@ export class Uploader {
477478 // If manually disabled or if the file is too small
478479 // TODO: support chunk uploading in public pages
479480 const maxChunkSize = getMaxChunksSize ( 'size' in file ? file . size : undefined )
480- const disabledChunkUpload = this . _isPublic
481+ const disabledChunkUpload = ! ( getCapabilities ( ) . dav [ 'public-shares-chunking' ] ?? false )
481482 || maxChunkSize === 0
482483 || ( 'size' in file && file . size < maxChunkSize )
483484
@@ -491,8 +492,16 @@ export class Uploader {
491492 if ( ! disabledChunkUpload ) {
492493 logger . debug ( 'Initializing chunked upload' , { file, upload } )
493494
495+ let chunksWorkspace : string
496+ if ( this . _isPublic ) {
497+ const shareToken = root ! . split ( '/' ) . at ( - 1 ) !
498+ chunksWorkspace = `${ getBaseUrl ( ) } /public.php/dav/uploads/${ shareToken } `
499+ } else {
500+ chunksWorkspace = generateRemoteUrl ( `dav/uploads/${ getCurrentUser ( ) ?. uid } ` )
501+ }
502+
494503 // Let's initialize a chunk upload
495- const tempUrl = await initChunkWorkspace ( encodedDestinationFile , retries )
504+ const tempUrl = await initChunkWorkspace ( chunksWorkspace , encodedDestinationFile , retries )
496505 const chunksQueue : Array < Promise < void > > = [ ]
497506
498507 // Generate chunks array
0 commit comments