CC-5786: Quota Enforcement in the File Upload API
This commit is contained in:
parent
7fbd285dd0
commit
4add0f0b7b
4 changed files with 38 additions and 3 deletions
|
@ -110,7 +110,7 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//If we do get an ID on a POST, then that doesn't make any sense
|
||||
//since POST is only for creating.
|
||||
if ($id = $this->_getParam('id', false)) {
|
||||
|
@ -120,6 +120,13 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
return;
|
||||
}
|
||||
|
||||
if (!$this->isEnoughDiskSpace()) {
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(400)
|
||||
->appendBody("ERROR: Disk Quota limit reached.");
|
||||
return;
|
||||
}
|
||||
|
||||
$file = new CcFiles();
|
||||
$whiteList = $this->removeBlacklistedFieldsFromRequestData($this->getRequest()->getPost());
|
||||
|
||||
|
@ -423,5 +430,19 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue