diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index 7e04657f5331..df3fd8e1a8f8 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -224,8 +224,8 @@ OC.FileUpload.prototype = { this.data.headers['X-OC-Mtime'] = file.lastModified / 1000; } - var userName = this.uploader.filesClient.getUserName(); - var password = this.uploader.filesClient.getPassword(); + var userName = this.uploader.davClient.getUserName(); + var password = this.uploader.davClient.getPassword(); if (userName) { // copy username/password from DAV client this.data.headers['Authorization'] = @@ -238,7 +238,7 @@ OC.FileUpload.prototype = { && this.getFile().size > this.uploader.fileUploadParam.maxChunkSize ) { data.isChunked = true; - chunkFolderPromise = this.uploader.filesClient.createDirectory( + chunkFolderPromise = this.uploader.davClient.createDirectory( 'uploads/' + encodeURIComponent(OC.getCurrentUser().uid) + '/' + encodeURIComponent(this.getId()) ); // TODO: if fails, it means same id already existed, need to retry @@ -264,7 +264,7 @@ OC.FileUpload.prototype = { } var uid = OC.getCurrentUser().uid; - return this.uploader.filesClient.move( + return this.uploader.davClient.move( 'uploads/' + encodeURIComponent(uid) + '/' + encodeURIComponent(this.getId()) + '/.file', 'files/' + encodeURIComponent(uid) + '/' + OC.joinPaths(this.getFullPath(), this.getFileName()) ); @@ -276,7 +276,7 @@ OC.FileUpload.prototype = { abort: function() { if (this.data.isChunked) { // delete transfer directory for this upload - this.uploader.filesClient.remove( + this.uploader.davClient.remove( 'uploads/' + encodeURIComponent(OC.getCurrentUser().uid) + '/' + encodeURIComponent(this.getId()) ); } @@ -379,6 +379,13 @@ OC.Uploader.prototype = _.extend({ */ filesClient: null, + /** + * Webdav client pointing at the root "dav" endpoint + * + * @type OC.Files.Client + */ + davClient: null, + /** * Function that will allow us to know if Ajax uploads are supported * @link https://github.com/New-Bamboo/example-ajax-upload/blob/master/public/index.html @@ -737,6 +744,13 @@ OC.Uploader.prototype = _.extend({ this.fileList = options.fileList; this.filesClient = options.filesClient || OC.Files.getClient(); + this.davClient = new OC.Files.Client({ + host: this.filesClient.getHost(), + root: OC.linkToRemoteBase('dav'), + useHTTPS: OC.getProtocol() === 'https', + userName: this.filesClient.getUserName(), + password: this.filesClient.getPassword() + }); $uploadEl = $($uploadEl); this.$uploadEl = $uploadEl; @@ -750,6 +764,7 @@ OC.Uploader.prototype = _.extend({ type: 'PUT', dropZone: options.dropZone, // restrict dropZone to content div autoUpload: false, + maxChunkSize: 10 * 1000 * 1000, // 10 MB sequentialUploads: true, //singleFileUploads is on by default, so the data.files array will always have length 1 /** diff --git a/core/js/files/client.js b/core/js/files/client.js index 16221839f820..e5d0087dcc6f 100644 --- a/core/js/files/client.js +++ b/core/js/files/client.js @@ -37,6 +37,7 @@ } url += options.host + this._root; + this._host = options.host; this._defaultHeaders = options.defaultHeaders || { 'X-Requested-With': 'XMLHttpRequest', 'requesttoken': OC.requestToken @@ -749,6 +750,16 @@ */ getBaseUrl: function() { return this._client.baseUrl; + }, + + /** + * Returns the host + * + * @since 9.2 + * @return {String} base URL + */ + getHost: function() { + return this._host; } }; @@ -786,7 +797,6 @@ var client = new OC.Files.Client({ host: OC.getHost(), - port: OC.getPort(), root: OC.linkToRemoteBase('webdav'), useHTTPS: OC.getProtocol() === 'https' });