diff options
author | Jan-Christoph Borchardt <hey@jancborchardt.net> | 2014-02-04 08:04:19 -0800 |
---|---|---|
committer | Jan-Christoph Borchardt <hey@jancborchardt.net> | 2014-02-04 08:04:19 -0800 |
commit | 0609f30d1c4ab01804d0ecf943c0d9146bb41cb7 (patch) | |
tree | 28f39a748ad378c20fbc12e7398d0df932441d31 /apps | |
parent | bd6734291cd56b4d3d494a6e4138435ecb49171e (diff) | |
parent | 099b71c712c38de7dac7e386252da02bb0cadf12 (diff) | |
download | nextcloud-server-0609f30d1c4ab01804d0ecf943c0d9146bb41cb7.tar.gz nextcloud-server-0609f30d1c4ab01804d0ecf943c0d9146bb41cb7.zip |
Merge pull request #6235 from NCTU-NBA/pr-exceed_upload_limit_msg
Change misleading message when file size exceeds upload limit
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/index.php | 6 | ||||
-rw-r--r-- | apps/files/js/file-upload.js | 18 | ||||
-rw-r--r-- | apps/files/js/files.js | 1 | ||||
-rw-r--r-- | apps/files/lib/helper.php | 1 | ||||
-rw-r--r-- | apps/files/templates/index.php | 5 | ||||
-rw-r--r-- | apps/files_sharing/public.php | 4 |
6 files changed, 29 insertions, 6 deletions
diff --git a/apps/files/index.php b/apps/files/index.php index 2ce8fdb065f..dd63f29bc28 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -101,6 +101,8 @@ if ($needUpgrade) { } else { // information about storage capacities $storageInfo=OC_Helper::getStorageInfo($dir); + $freeSpace=$storageInfo['free']; + $uploadLimit=OCP\Util::uploadLimit(); $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); $publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes'); // if the encryption app is disabled, than everything is fine (INIT_SUCCESSFUL status code) @@ -132,8 +134,10 @@ if ($needUpgrade) { $tmpl->assign('files', $files); $tmpl->assign('trash', $trashEnabled); $tmpl->assign('trashEmpty', $trashEmpty); - $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); + $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); // minimium of freeSpace and uploadLimit $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); + $tmpl->assign('freeSpace', $freeSpace); + $tmpl->assign('uploadLimit', $uploadLimit); // PHP upload limit $tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']); $tmpl->assign('isPublic', false); diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index 486273a910c..149e4a9666b 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -241,10 +241,22 @@ $(document).ready(function() { // add size selection.totalBytes += file.size; - //check max upload size - if (selection.totalBytes > $('#max_upload').val()) { + // check PHP upload limit + if (selection.totalBytes > $('#upload_limit').val()) { + data.textStatus = 'sizeexceedlimit'; + data.errorThrown = t('files', 'Total file size {size1} exceeds upload limit {size2}', { + 'size1': humanFileSize(selection.totalBytes), + 'size2': humanFileSize($('#upload_limit').val()) + }); + } + + // check free space + if (selection.totalBytes > $('#free_space').val()) { data.textStatus = 'notenoughspace'; - data.errorThrown = t('files', 'Not enough space available'); + data.errorThrown = t('files', 'Not enough free space, you are uploading {size1} but only {size2} is left', { + 'size1': humanFileSize(selection.totalBytes), + 'size2': humanFileSize($('#free_space').val()) + }); } // end upload for whole selection on error diff --git a/apps/files/js/files.js b/apps/files/js/files.js index d794a1584de..06f37da4b5c 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -41,6 +41,7 @@ Files={ } if (response.data !== undefined && response.data.uploadMaxFilesize !== undefined) { $('#max_upload').val(response.data.uploadMaxFilesize); + $('#free_space').val(response.data.freeSpace); $('#upload.button').attr('original-title', response.data.maxHumanFilesize); $('#usedSpacePercent').val(response.data.usedSpacePercent); Files.displayStorageWarnings(); diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php index eaff28178ea..21d1f50e587 100644 --- a/apps/files/lib/helper.php +++ b/apps/files/lib/helper.php @@ -15,6 +15,7 @@ class Helper return array('uploadMaxFilesize' => $maxUploadFilesize, 'maxHumanFilesize' => $maxHumanFilesize, + 'freeSpace' => $storageInfo['free'], 'usedSpacePercent' => (int)$storageInfo['relative']); } diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index ff78f0ca551..939043b2c9f 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -17,9 +17,10 @@ <div id="upload" class="button" title="<?php p($l->t('Upload') . ' max. '.$_['uploadMaxHumanFilesize']) ?>"> <?php if($_['uploadMaxFilesize'] >= 0):?> - <input type="hidden" name="MAX_FILE_SIZE" id="max_upload" - value="<?php p($_['uploadMaxFilesize']) ?>"> + <input type="hidden" id="max_upload" name="MAX_FILE_SIZE" value="<?php p($_['uploadMaxFilesize']) ?>"> <?php endif;?> + <input type="hidden" id="upload_limit" value="<?php p($_['uploadLimit']) ?>"> + <input type="hidden" id="free_space" value="<?php p($_['freeSpace']) ?>"> <?php if(isset($_['dirToken'])):?> <input type="hidden" id="publicUploadRequestToken" name="requesttoken" value="<?php p($_['requesttoken']) ?>" /> <input type="hidden" id="dirToken" name="dirToken" value="<?php p($_['dirToken']) ?>" /> diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 0ca923fff08..b187da41324 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -143,6 +143,8 @@ if (isset($path)) { OCP\Util::addScript('files', 'jquery.iframe-transport'); OCP\Util::addScript('files', 'jquery.fileupload'); $maxUploadFilesize=OCP\Util::maxUploadFilesize($path); + $freeSpace=OCP\Util::freeSpace($dir); + $uploadLimit=OCP\Util::uploadLimit(); $tmpl = new OCP\Template('files_sharing', 'public', 'base'); $tmpl->assign('uidOwner', $shareOwner); $tmpl->assign('displayName', \OCP\User::getDisplayName($shareOwner)); @@ -162,6 +164,8 @@ if (isset($path)) { } $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); + $tmpl->assign('freeSpace', $freeSpace); + $tmpl->assign('uploadLimit', $uploadLimit); // PHP upload limit $urlLinkIdentifiers= (isset($token)?'&t='.$token:'') .(isset($_GET['dir'])?'&dir='.$_GET['dir']:'') |