public function UploaderServlet::doPost in N1ED - Visual editor as CKEditor plugin with Bootstrap support 8.2
Processes POST HTTP request.
File
- src/
Flmngr/ FileUploaderServer/ servlet/ UploaderServlet.php, line 118
Class
- UploaderServlet
- Uploader servlet (ported from Java). Stores available action processors, routes request to one of them and returns JSON formed by request processor.
Namespace
Drupal\n1ed\Flmngr\FileUploaderServer\servletCode
public function doPost(RequestStack $request_stack, $files) {
$this
->addHeaders();
$resp = null;
$strResp = null;
try {
$req = null;
try {
$req = $this
->getReq($request_stack, $files);
} catch (Exception $e) {
error_log($e);
}
if ($req === null) {
$req = new ReqError(Message::createMessage(Message::MALFORMED_REQUEST));
}
$resp = $this->uploader
->run($req);
if ($resp === null) {
throw new Exception("Null response as result");
}
$strResp = $this->json
->toJson($resp);
} catch (Exception $e) {
error_log($e);
$resp = new RespFail(Message::createMessage(Message::INTERNAL_ERROR));
$strResp = $this->json
->toJson($resp);
}
try {
http_response_code(200);
header('Content-Type: application/json; charset=UTF-8');
print $strResp;
die;
} catch (Exception $e) {
error_log($e);
}
}