From f39de4ab375740469581809140e6dd01941e4ce1 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Thu, 10 Aug 2017 12:23:20 +0200 Subject: Transmit OC-Total-Length in browser as well MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- apps/files/js/file-upload.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'apps/files/js') diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index d1730fa7bc7..1586aa3324f 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -264,7 +264,10 @@ OC.FileUpload.prototype = { 'uploads/' + encodeURIComponent(uid) + '/' + encodeURIComponent(this.getId()) + '/.file', 'files/' + encodeURIComponent(uid) + '/' + OC.joinPaths(this.getFullPath(), this.getFileName()), true, - {'X-OC-Mtime': this.getFile().lastModified / 1000} + { + 'X-OC-Mtime': this.getFile().lastModified / 1000, + 'OC-Total-Length': this.getFile().size + } ); }, -- cgit v1.2.3 From ec8bf5335618b0b60737ff9a8945d2a835933259 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 11 Aug 2017 12:01:04 +0200 Subject: Only set X-OC-Mtime when browser provided lastModified on upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- apps/files/js/file-upload.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index 1586aa3324f..8e72b3cdb41 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -260,14 +260,22 @@ OC.FileUpload.prototype = { } var uid = OC.getCurrentUser().uid; + var mtime = this.getFile().lastModified; + var size = this.getFile().size; + var headers = {}; + if (mtime) { + headers['X-OC-Mtime'] = mtime / 1000; + } + if (size) { + headers['OC-Total-Length'] = size; + + } + return this.uploader.davClient.move( 'uploads/' + encodeURIComponent(uid) + '/' + encodeURIComponent(this.getId()) + '/.file', 'files/' + encodeURIComponent(uid) + '/' + OC.joinPaths(this.getFullPath(), this.getFileName()), true, - { - 'X-OC-Mtime': this.getFile().lastModified / 1000, - 'OC-Total-Length': this.getFile().size - } + headers ); }, -- cgit v1.2.3