CC-5786: Quota Enforcement in the File Upload API
This commit is contained in:
parent
7fbd285dd0
commit
4add0f0b7b
|
@ -25,6 +25,11 @@ class PluploadController extends Zend_Controller_Action
|
||||||
|
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'css/plupload.queue.css?'.$CC_CONFIG['airtime_version']);
|
$this->view->headLink()->appendStylesheet($baseUrl.'css/plupload.queue.css?'.$CC_CONFIG['airtime_version']);
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'css/addmedia.css?'.$CC_CONFIG['airtime_version']);
|
$this->view->headLink()->appendStylesheet($baseUrl.'css/addmedia.css?'.$CC_CONFIG['airtime_version']);
|
||||||
|
|
||||||
|
$this->view->quotaLimitReached = false;
|
||||||
|
if (Application_Model_Preference::getDiskUsage() > Application_Model_Preference::getDiskQuota()) {
|
||||||
|
$this->view->quotaLimitReached = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function recentUploadsAction()
|
public function recentUploadsAction()
|
||||||
|
|
|
@ -110,7 +110,7 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//If we do get an ID on a POST, then that doesn't make any sense
|
//If we do get an ID on a POST, then that doesn't make any sense
|
||||||
//since POST is only for creating.
|
//since POST is only for creating.
|
||||||
if ($id = $this->_getParam('id', false)) {
|
if ($id = $this->_getParam('id', false)) {
|
||||||
|
@ -120,6 +120,13 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$this->isEnoughDiskSpace()) {
|
||||||
|
$this->getResponse()
|
||||||
|
->setHttpResponseCode(400)
|
||||||
|
->appendBody("ERROR: Disk Quota limit reached.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$file = new CcFiles();
|
$file = new CcFiles();
|
||||||
$whiteList = $this->removeBlacklistedFieldsFromRequestData($this->getRequest()->getPost());
|
$whiteList = $this->removeBlacklistedFieldsFromRequestData($this->getRequest()->getPost());
|
||||||
|
|
||||||
|
@ -423,5 +430,19 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Checks if there is enough disk space to upload the file in question
|
||||||
|
* We allow one file to exceed to the disk quota so it is possible for the
|
||||||
|
* disk usage to be greater than the disk usage value
|
||||||
|
*/
|
||||||
|
private function isEnoughDiskSpace()
|
||||||
|
{
|
||||||
|
if (Application_Model_Preference::getDiskUsage() < Application_Model_Preference::GetDiskQuota()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,15 @@
|
||||||
#plupload_files input[type="file"] {
|
#plupload_files input[type="file"] {
|
||||||
font-size: 200px !important;
|
font-size: 200px !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<form id="plupload_form">
|
<?php if ($this->quotaLimitReached) { ?>
|
||||||
|
<div class="errors quota-reached">
|
||||||
|
Disk quota exceeded. You cannot upload files until you <a href="http://www.sourcefabric.org/en/airtime" target="_blank">upgrade your storage</a>.
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<form id="plupload_form" <?php if ($this->quotaLimitReached) { ?> class="hidden" <?php } ?>>
|
||||||
<div id="plupload_files"></div>
|
<div id="plupload_files"></div>
|
||||||
</form>
|
</form>
|
||||||
<div id="plupload_error">
|
<div id="plupload_error">
|
||||||
|
|
|
@ -3087,3 +3087,5 @@ dd .stream-status {
|
||||||
#popup-share-link {
|
#popup-share-link {
|
||||||
width: 320px;
|
width: 320px;
|
||||||
}
|
}
|
||||||
|
.quota-reached {
|
||||||
|
font-size: 14px !important;
|
||||||
|
|
Loading…
Reference in New Issue