Working state
This commit is contained in:
@@ -103,12 +103,10 @@ final class MediaController
|
||||
return $this->jsonError($res, $e->getMessage(), 500);
|
||||
}
|
||||
|
||||
$res->getBody()->write(json_encode([
|
||||
'success' => true,
|
||||
'url' => $url,
|
||||
], JSON_THROW_ON_ERROR));
|
||||
|
||||
return $res->withHeader('Content-Type', 'application/json')->withStatus(200);
|
||||
return $this->jsonOk($res, [
|
||||
'url' => $url,
|
||||
'file' => $url,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,21 +148,21 @@ final class MediaController
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne une réponse JSON de succès avec l'URL du fichier uploadé.
|
||||
* Retourne une réponse JSON de succès.
|
||||
*
|
||||
* @param Response $res La réponse HTTP
|
||||
* @param string $fileUrl L'URL publique du fichier
|
||||
* @param Response $res La réponse HTTP
|
||||
* @param array<string, mixed> $data Données supplémentaires à fusionner
|
||||
*
|
||||
* @return Response La réponse JSON {"success": true, "file": "..."}
|
||||
* @return Response La réponse JSON {"success": true, ...}
|
||||
*/
|
||||
private function jsonSuccess(Response $res, string $fileUrl): Response
|
||||
private function jsonOk(Response $res, array $data = []): Response
|
||||
{
|
||||
$res->getBody()->write(json_encode([
|
||||
'success' => true,
|
||||
'file' => $fileUrl,
|
||||
], JSON_THROW_ON_ERROR));
|
||||
$payload = json_encode(array_merge(['success' => true], $data), JSON_THROW_ON_ERROR);
|
||||
$res->getBody()->write($payload);
|
||||
|
||||
return $res->withHeader('Content-Type', 'application/json')->withStatus(200);
|
||||
return $res
|
||||
->withHeader('Content-Type', 'application/json')
|
||||
->withStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user