public function validate_upload(UploadedFile $file) {
		foreach ($this->restrictions as $k => $v) {
			switch ($k) {
				case 'maxsize':
					if ($v < $file->get_size()) {
						throw new Exception('Received file was too large.', Exception::ERR_BAD_REQUEST);
					}
					break;

				case 'mediatype':
					if (!in_array($file->get_mediatype(), $v)) {
						throw new Exception('Files with that extension are not allowed.', Exception::ERR_BAD_REQUEST);
					}
					break;

				case 'mimetype':
					if (!in_array($file->get_type(), $v)) {
						throw new Exception('Files with that extension are not allowed.', Exception::ERR_BAD_REQUEST);
					}
					break;

				case 'extension':
					if (!in_array($file->get_file_extension(), $v)) {
						throw new Exception('Files with that extension are not allowed.', Exception::ERR_BAD_REQUEST);
					}
					break;
			}
		}
		return true;
	}