aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/ajax
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-06-29 15:20:47 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-07-07 13:56:49 +0200
commite557fe0aabe9e1e97249aa5446eef30c804da79f (patch)
tree037e1d9ec9f10f3b901892d08f8beec2c9b6bd6b /apps/files/ajax
parent5a528214b8c6326590c8ff6784187c4191d64f56 (diff)
downloadnextcloud-server-e557fe0aabe9e1e97249aa5446eef30c804da79f.tar.gz
nextcloud-server-e557fe0aabe9e1e97249aa5446eef30c804da79f.zip
Add proper download started feedback
* this code adds a cookie when a special get parameter is set * the content of this get parameter is used as value for the cookie * the cookie expires after 20 seconds * the JS code checks every 500 milliseconds for the cookie -> if the cookie is set the request returned and the download is started
Diffstat (limited to 'apps/files/ajax')
-rw-r--r--apps/files/ajax/download.php11
1 files changed, 11 insertions, 0 deletions
diff --git a/apps/files/ajax/download.php b/apps/files/ajax/download.php
index e67635ab853..26bab8837b4 100644
--- a/apps/files/ajax/download.php
+++ b/apps/files/ajax/download.php
@@ -39,4 +39,15 @@ if (!is_array($files_list)) {
$files_list = array($files);
}
+/**
+ * this sets a cookie to be able to recognize the start of the download
+ * the content must not be longer than 32 characters and must only contain
+ * alphanumeric characters
+ */
+if(isset($_GET['downloadStartSecret'])
+ && !isset($_GET['downloadStartSecret'][32])
+ && preg_match('!^[a-zA-Z0-9]+$!', $_GET['downloadStartSecret']) === 1) {
+ setcookie('ocDownloadStarted', $_GET['downloadStartSecret'], time() + 20, '/');
+}
+
OC_Files::get($dir, $files_list, $_SERVER['REQUEST_METHOD'] == 'HEAD');