diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-10-22 22:13:18 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-10-24 21:45:00 +0200 |
commit | 7a6dbeb3986b76740a4b19ea3553118d226f51c7 (patch) | |
tree | 4cb6cb43fe53187631671f325ced010964dadefd /apps/files_sharing/js/files_drop.js | |
parent | e73a11d1060320917343679b15c126f0076ac46b (diff) | |
download | nextcloud-server-7a6dbeb3986b76740a4b19ea3553118d226f51c7.tar.gz nextcloud-server-7a6dbeb3986b76740a4b19ea3553118d226f51c7.zip |
Make files_drop work
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/files_sharing/js/files_drop.js')
-rw-r--r-- | apps/files_sharing/js/files_drop.js | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/apps/files_sharing/js/files_drop.js b/apps/files_sharing/js/files_drop.js index 984eb06b9e3..aa993635b58 100644 --- a/apps/files_sharing/js/files_drop.js +++ b/apps/files_sharing/js/files_drop.js @@ -22,22 +22,46 @@ _template: undefined, initialize: function () { + + var filesClient = new OC.Files.Client({ + host: OC.getHost(), + port: OC.getPort(), + userName: $('#sharingToken').val(), + // note: password not be required, the endpoint + // will recognize previous validation from the session + root: OC.getRootPath() + '/public.php/webdav', + useHTTPS: OC.getProtocol() === 'https' + }); + $(document).bind('drop dragover', function (e) { // Prevent the default browser drop action: e.preventDefault(); }); var output = this.template(); $('#public-upload').fileupload({ - url: OC.linkTo('files', 'ajax/upload.php'), - dataType: 'json', + type: 'PUT', dropZone: $('#public-upload'), - formData: { - dirToken: $('#sharingToken').val() - }, + sequentialUploads: true, add: function(e, data) { var errors = []; - if(data.files[0]['size'] && data.files[0]['size'] > $('#maxFilesizeUpload').val()) { - errors.push('File is too big'); + + var name = data.files[0].name; + + var base = OC.getProtocol() + '://' + OC.getHost(); + data.url = base + OC.getRootPath() + '/public.php/webdav/' + encodeURI(name); + + data.multipart = false; + + if (!data.headers) { + data.headers = {}; + } + + var userName = filesClient.getUserName(); + var password = filesClient.getPassword(); + if (userName) { + // copy username/password from DAV client + data.headers['Authorization'] = + 'Basic ' + btoa(userName + ':' + (password || '')); } $('#drop-upload-done-indicator').addClass('hidden'); @@ -53,6 +77,8 @@ $('[data-toggle="tooltip"]').tooltip(); } }); + + return true; }, success: function (response) { if(response.status !== 'error') { |