diff options
author | Morris Jobke <morris.jobke@gmail.com> | 2014-01-29 00:39:14 -0800 |
---|---|---|
committer | Morris Jobke <morris.jobke@gmail.com> | 2014-01-29 00:39:14 -0800 |
commit | cf2c061f1f2577b3a995d9e2423c93589d7df2b3 (patch) | |
tree | 43cf27eac956eff737b2a5edfcab429c811e403e /apps/files/js | |
parent | 75c8d74c945293a65f0009caeb5a1ba33f21e37b (diff) | |
parent | c6695bbd764be9f43067c09894e36422c2b92b49 (diff) | |
download | nextcloud-server-cf2c061f1f2577b3a995d9e2423c93589d7df2b3.tar.gz nextcloud-server-cf2c061f1f2577b3a995d9e2423c93589d7df2b3.zip |
Merge pull request #6929 from owncloud/sharing-fixfiledownloadlink
Sharing fixfiledownloadlink
Diffstat (limited to 'apps/files/js')
-rw-r--r-- | apps/files/js/fileactions.js | 5 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 14 |
2 files changed, 18 insertions, 1 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 74bb711ef3d..eb59e71a030 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -173,7 +173,10 @@ $(document).ready(function () { FileActions.register(downloadScope, 'Download', OC.PERMISSION_READ, function () { return OC.imagePath('core', 'actions/download'); }, function (filename) { - window.location = OC.filePath('files', 'ajax', 'download.php') + '?files=' + encodeURIComponent(filename) + '&dir=' + encodeURIComponent($('#dir').val()); + var url = FileList.getDownloadUrl(filename); + if (url) { + OC.redirect(url); + } }); } $('#fileList tr').each(function () { diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 66968ab54c7..63fd0f4ce05 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -780,6 +780,20 @@ var FileList={ $('#fileList tr.searchresult').each(function(i,e) { $(e).removeClass("searchresult"); }); + }, + + /** + * Returns the download URL of the given file + * @param filename file name of the file + * @param dir optional directory in which the file name is, defaults to the current directory + */ + getDownloadUrl: function(filename, dir) { + var params = { + files: filename, + dir: dir || FileList.getCurrentDirectory(), + download: null + }; + return OC.filePath('files', 'ajax', 'download.php') + '?' + OC.buildQueryString(params); } }; |