@@ -224,8 +224,8 @@ OC.FileUpload.prototype = {
224224 this . data . headers [ 'X-OC-Mtime' ] = file . lastModified / 1000 ;
225225 }
226226
227- var userName = this . uploader . filesClient . getUserName ( ) ;
228- var password = this . uploader . filesClient . getPassword ( ) ;
227+ var userName = this . uploader . davClient . getUserName ( ) ;
228+ var password = this . uploader . davClient . getPassword ( ) ;
229229 if ( userName ) {
230230 // copy username/password from DAV client
231231 this . data . headers [ 'Authorization' ] =
@@ -238,7 +238,7 @@ OC.FileUpload.prototype = {
238238 && this . getFile ( ) . size > this . uploader . fileUploadParam . maxChunkSize
239239 ) {
240240 data . isChunked = true ;
241- chunkFolderPromise = this . uploader . filesClient . createDirectory (
241+ chunkFolderPromise = this . uploader . davClient . createDirectory (
242242 'uploads/' + encodeURIComponent ( OC . getCurrentUser ( ) . uid ) + '/' + encodeURIComponent ( this . getId ( ) )
243243 ) ;
244244 // TODO: if fails, it means same id already existed, need to retry
@@ -264,7 +264,7 @@ OC.FileUpload.prototype = {
264264 }
265265
266266 var uid = OC . getCurrentUser ( ) . uid ;
267- return this . uploader . filesClient . move (
267+ return this . uploader . davClient . move (
268268 'uploads/' + encodeURIComponent ( uid ) + '/' + encodeURIComponent ( this . getId ( ) ) + '/.file' ,
269269 'files/' + encodeURIComponent ( uid ) + '/' + OC . joinPaths ( this . getFullPath ( ) , this . getFileName ( ) )
270270 ) ;
@@ -276,7 +276,7 @@ OC.FileUpload.prototype = {
276276 abort : function ( ) {
277277 if ( this . data . isChunked ) {
278278 // delete transfer directory for this upload
279- this . uploader . filesClient . remove (
279+ this . uploader . davClient . remove (
280280 'uploads/' + encodeURIComponent ( OC . getCurrentUser ( ) . uid ) + '/' + encodeURIComponent ( this . getId ( ) )
281281 ) ;
282282 }
@@ -379,6 +379,13 @@ OC.Uploader.prototype = _.extend({
379379 */
380380 filesClient : null ,
381381
382+ /**
383+ * Webdav client pointing at the root "dav" endpoint
384+ *
385+ * @type OC.Files.Client
386+ */
387+ davClient : null ,
388+
382389 /**
383390 * Function that will allow us to know if Ajax uploads are supported
384391 * @link https://github.com/New-Bamboo/example-ajax-upload/blob/master/public/index.html
@@ -737,6 +744,13 @@ OC.Uploader.prototype = _.extend({
737744
738745 this . fileList = options . fileList ;
739746 this . filesClient = options . filesClient || OC . Files . getClient ( ) ;
747+ this . davClient = new OC . Files . Client ( {
748+ host : this . filesClient . getHost ( ) ,
749+ root : OC . linkToRemoteBase ( 'dav' ) ,
750+ useHTTPS : OC . getProtocol ( ) === 'https' ,
751+ userName : this . filesClient . getUserName ( ) ,
752+ password : this . filesClient . getPassword ( )
753+ } ) ;
740754
741755 $uploadEl = $ ( $uploadEl ) ;
742756 this . $uploadEl = $uploadEl ;
@@ -750,6 +764,7 @@ OC.Uploader.prototype = _.extend({
750764 type : 'PUT' ,
751765 dropZone : options . dropZone , // restrict dropZone to content div
752766 autoUpload : false ,
767+ maxChunkSize : 10 * 1000 * 1000 , // 10 MB
753768 sequentialUploads : true ,
754769 //singleFileUploads is on by default, so the data.files array will always have length 1
755770 /**
0 commit comments