diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-10-25 10:31:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-25 10:31:03 +0200 |
commit | 79706e0ddc6ab970d5709e89b8d0caec4d34662b (patch) | |
tree | 168f9bc806e7eed287bce63e7f6d277eb5adb956 /apps/files_sharing/js/public.js | |
parent | 5926da3dd6535e0eea7fe7871d2347f8b33bb337 (diff) | |
parent | c8a13f644ebbc5840d0e632cf86e5ae46856f7f0 (diff) | |
download | nextcloud-server-79706e0ddc6ab970d5709e89b8d0caec4d34662b.tar.gz nextcloud-server-79706e0ddc6ab970d5709e89b8d0caec4d34662b.zip |
Merge pull request #1283 from nextcloud/us_files-ui-webdav-upload
Use Webdav PUT for uploads
Diffstat (limited to 'apps/files_sharing/js/public.js')
-rw-r--r-- | apps/files_sharing/js/public.js | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index 0dfff235998..0045c7156d2 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -72,7 +72,8 @@ OCA.Sharing.PublicApp = { folderDropOptions: folderDropOptions, fileActions: fileActions, detailsViewEnabled: false, - filesClient: filesClient + filesClient: filesClient, + enableUpload: true } ); this.files = OCA.Files.Files; @@ -170,6 +171,30 @@ OCA.Sharing.PublicApp = { return OC.generateUrl('/s/' + token + '/download') + '?' + OC.buildQueryString(params); }; + this.fileList.getUploadUrl = function(fileName, dir) { + if (_.isUndefined(dir)) { + dir = this.getCurrentDirectory(); + } + + var pathSections = dir.split('/'); + if (!_.isUndefined(fileName)) { + pathSections.push(fileName); + } + var encodedPath = ''; + _.each(pathSections, function(section) { + if (section !== '') { + encodedPath += '/' + encodeURIComponent(section); + } + }); + var base = ''; + + if (!this._uploader.isXHRUpload()) { + // also add auth in URL due to POST workaround + base = OC.getProtocol() + '://' + token + '@' + OC.getHost() + (OC.getPort() ? ':' + OC.getPort() : ''); + } + return base + OC.getRootPath() + '/public.php/webdav' + encodedPath; + }; + this.fileList.getAjaxUrl = function (action, params) { params = params || {}; params.t = token; @@ -203,20 +228,12 @@ OCA.Sharing.PublicApp = { OCA.Files.FileList.prototype.updateEmptyContent.apply(this, arguments); }; - var file_upload_start = $('#file_upload_start'); - file_upload_start.on('fileuploadadd', function (e, data) { - var fileDirectory = ''; - if (typeof data.files[0].relativePath !== 'undefined') { - fileDirectory = data.files[0].relativePath; + this.fileList._uploader.on('fileuploadadd', function(e, data) { + if (!data.headers) { + data.headers = {}; } - // Add custom data to the upload handler - data.formData = { - requesttoken: $('#publicUploadRequestToken').val(), - dirToken: $('#dirToken').val(), - subdir: data.targetDir || self.fileList.getCurrentDirectory(), - file_directory: fileDirectory - }; + data.headers.Authorization = 'Basic ' + btoa(token + ':'); }); // do not allow sharing from the public page |