@@ -244,8 +244,8 @@ OC.FileUpload.prototype = {
244244 this . data . headers [ 'X-OC-Mtime' ] = file . lastModified / 1000 ;
245245 }
246246
247- var userName = this . uploader . filesClient . getUserName ( ) ;
248- var password = this . uploader . filesClient . getPassword ( ) ;
247+ var userName = this . uploader . davClient . getUserName ( ) ;
248+ var password = this . uploader . davClient . getPassword ( ) ;
249249 if ( userName ) {
250250 // copy username/password from DAV client
251251 this . data . headers [ 'Authorization' ] =
@@ -258,7 +258,7 @@ OC.FileUpload.prototype = {
258258 && this . getFile ( ) . size > this . uploader . fileUploadParam . maxChunkSize
259259 ) {
260260 data . isChunked = true ;
261- chunkFolderPromise = this . uploader . filesClient . createDirectory (
261+ chunkFolderPromise = this . uploader . davClient . createDirectory (
262262 'uploads/' + encodeURIComponent ( OC . getCurrentUser ( ) . uid ) + '/' + encodeURIComponent ( this . getId ( ) )
263263 ) ;
264264 // TODO: if fails, it means same id already existed, need to retry
@@ -284,7 +284,7 @@ OC.FileUpload.prototype = {
284284 }
285285
286286 var uid = OC . getCurrentUser ( ) . uid ;
287- return this . uploader . filesClient . move (
287+ return this . uploader . davClient . move (
288288 'uploads/' + encodeURIComponent ( uid ) + '/' + encodeURIComponent ( this . getId ( ) ) + '/.file' ,
289289 'files/' + encodeURIComponent ( uid ) + '/' + OC . joinPaths ( this . getFullPath ( ) , this . getFileName ( ) )
290290 ) ;
@@ -296,7 +296,7 @@ OC.FileUpload.prototype = {
296296 abort : function ( ) {
297297 if ( this . data . isChunked ) {
298298 // delete transfer directory for this upload
299- this . uploader . filesClient . remove (
299+ this . uploader . davClient . remove (
300300 'uploads/' + encodeURIComponent ( OC . getCurrentUser ( ) . uid ) + '/' + encodeURIComponent ( this . getId ( ) )
301301 ) ;
302302 }
@@ -399,6 +399,13 @@ OC.Uploader.prototype = _.extend({
399399 */
400400 filesClient : null ,
401401
402+ /**
403+ * Webdav client pointing at the root "dav" endpoint
404+ *
405+ * @type OC.Files.Client
406+ */
407+ davClient : null ,
408+
402409 /**
403410 * Function that will allow us to know if Ajax uploads are supported
404411 * @link https://github.com/New-Bamboo/example-ajax-upload/blob/master/public/index.html
@@ -758,6 +765,13 @@ OC.Uploader.prototype = _.extend({
758765
759766 this . fileList = options . fileList ;
760767 this . filesClient = options . filesClient || OC . Files . getClient ( ) ;
768+ this . davClient = new OC . Files . Client ( {
769+ host : this . filesClient . getHost ( ) ,
770+ root : OC . linkToRemoteBase ( 'dav' ) ,
771+ useHTTPS : OC . getProtocol ( ) === 'https' ,
772+ userName : this . filesClient . getUserName ( ) ,
773+ password : this . filesClient . getPassword ( )
774+ } ) ;
761775
762776 if ( options . url ) {
763777 this . url = options . url ;
@@ -775,6 +789,7 @@ OC.Uploader.prototype = _.extend({
775789 type : 'PUT' ,
776790 dropZone : options . dropZone , // restrict dropZone to content div
777791 autoUpload : false ,
792+ maxChunkSize : 10 * 1000 * 1000 , // 10 MB
778793 sequentialUploads : true ,
779794 //singleFileUploads is on by default, so the data.files array will always have length 1
780795 /**
0 commit comments