aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-09-03 18:06:35 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-10-24 21:45:00 +0200
commitf374eb5f1df6f84f94847dae2ee5700436322b50 (patch)
treed174bd2cb80464afe75ffe4ce16bb2e63dd42ead /apps/files/js
parentf72ffa2f119f0b2644380e5c92f50dd2f05b6531 (diff)
downloadnextcloud-server-f374eb5f1df6f84f94847dae2ee5700436322b50.tar.gz
nextcloud-server-f374eb5f1df6f84f94847dae2ee5700436322b50.zip
More fixes to file upload
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/file-upload.js28
-rw-r--r--apps/files/js/filelist.js24
2 files changed, 31 insertions, 21 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index b75505c5dfb..30784528700 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -204,6 +204,14 @@ OC.FileUpload.prototype = {
this.data.headers['X-OC-Mtime'] = file.lastModified / 1000;
}
+ var userName = this.uploader.filesClient.getUserName();
+ var password = this.uploader.filesClient.getPassword();
+ if (userName) {
+ // copy username/password from DAV client
+ this.data.headers['Authorization'] =
+ 'Basic ' + btoa(userName + ':' + (password || ''));
+ }
+
if (!this.uploader.isXHRUpload()) {
data.formData = [];
@@ -222,7 +230,7 @@ OC.FileUpload.prototype = {
&& this.getFile().size > this.uploader.fileUploadParam.maxChunkSize
) {
data.isChunked = true;
- chunkFolderPromise = this.uploader.davClient.createDirectory(
+ chunkFolderPromise = this.uploader.filesClient.createDirectory(
'uploads/' + encodeURIComponent(OC.getCurrentUser().uid) + '/' + encodeURIComponent(this.getId())
);
// TODO: if fails, it means same id already existed, need to retry
@@ -248,7 +256,7 @@ OC.FileUpload.prototype = {
}
var uid = OC.getCurrentUser().uid;
- return this.uploader.davClient.move(
+ return this.uploader.filesClient.move(
'uploads/' + encodeURIComponent(uid) + '/' + encodeURIComponent(this.getId()) + '/.file',
'files/' + encodeURIComponent(uid) + '/' + OC.joinPaths(this.getFullPath(), this.getFileName())
);
@@ -260,7 +268,7 @@ OC.FileUpload.prototype = {
abort: function() {
if (this.data.isChunked) {
// delete transfer directory for this upload
- this.uploader.davClient.remove(
+ this.uploader.filesClient.remove(
'uploads/' + encodeURIComponent(OC.getCurrentUser().uid) + '/' + encodeURIComponent(this.getId())
);
}
@@ -343,7 +351,7 @@ OC.Uploader.prototype = _.extend({
/**
* @type Array<OC.FileUpload>
*/
- _uploads: [],
+ _uploads: {},
/**
* List of directories known to exist.
@@ -586,7 +594,7 @@ OC.Uploader.prototype = _.extend({
onReplace:function(upload) {
this.log('replace', null, upload);
upload.setConflictMode(OC.FileUpload.CONFLICT_MODE_OVERWRITE);
- upload.submit();
+ this.submitUploads([upload]);
},
/**
* handle uploading a file and letting the server decide a new name
@@ -595,7 +603,7 @@ OC.Uploader.prototype = _.extend({
onAutorename:function(upload) {
this.log('autorename', null, upload);
upload.setConflictMode(OC.FileUpload.CONFLICT_MODE_AUTORENAME);
- upload.submit();
+ this.submitUploads([upload]);
},
_trace:false, //TODO implement log handler for JS per class?
log:function(caption, e, data) {
@@ -707,19 +715,13 @@ OC.Uploader.prototype = _.extend({
this.fileList = options.fileList;
this.filesClient = options.filesClient || OC.Files.getClient();
- this.davClient = new OC.Files.Client({
- host: OC.getHost(),
- port: OC.getPort(),
- root: OC.getRootPath() + '/remote.php/dav/',
- useHTTPS: OC.getProtocol() === 'https'
- });
$uploadEl = $($uploadEl);
this.$uploadEl = $uploadEl;
if ($uploadEl.exists()) {
$('#uploadprogresswrapper .stop').on('click', function() {
- this.cancelUploads();
+ self.cancelUploads();
});
this.fileUploadParam = {
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index d4a223058b4..d932c06d853 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -2786,8 +2786,13 @@
if (OC.isSamePath(OC.dirname(upload.getFullPath() + '/'), self.getCurrentDirectory())) {
self._uploads[fileName] = fetchInfoPromise;
}
+
+ var uploadText = self.$fileList.find('tr .uploadtext');
+ self.showFileBusyState(uploadText.closest('tr'), false);
+ uploadText.fadeOut();
+ uploadText.attr('currentUploads', 0);
});
- uploader.on('createdfolder', function(e, fullPath) {
+ uploader.on('createdfolder', function(fullPath) {
self.addAndFetchFileInfo(OC.basename(fullPath), OC.dirname(fullPath));
});
uploader.on('stop', function() {
@@ -2805,6 +2810,11 @@
self.highlightFiles(fileNames);
});
self.updateStorageStatistics();
+
+ var uploadText = self.$fileList.find('tr .uploadtext');
+ self.showFileBusyState(uploadText.closest('tr'), false);
+ uploadText.fadeOut();
+ uploadText.attr('currentUploads', 0);
});
uploader.on('fail', function(e, data) {
self._uploader.log('filelist handle fileuploadfail', e, data);
@@ -2812,13 +2822,11 @@
self._uploads = [];
//if user pressed cancel hide upload chrome
- if (data.errorThrown === 'abort') {
- //cleanup uploading to a dir
- var uploadText = self.$fileList.find('tr .uploadtext');
- self.showFileBusyState(uploadText.closest('tr'), false);
- uploadText.fadeOut();
- uploadText.attr('currentUploads', 0);
- }
+ //cleanup uploading to a dir
+ var uploadText = self.$fileList.find('tr .uploadtext');
+ self.showFileBusyState(uploadText.closest('tr'), false);
+ uploadText.fadeOut();
+ uploadText.attr('currentUploads', 0);
self.updateStorageStatistics();
});