Only set X-OC-Mtime when browser provided lastModified on upload

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Vincent Petry 2017-08-11 12:01:04 +02:00 committed by Daniel Calviño Sánchez
parent f39de4ab37
commit ec8bf53356
1 changed files with 12 additions and 4 deletions

View File

@ -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
);
},