route post pour zip file

This commit is contained in:
Alexandre_BRAVO 2024-11-19 15:29:48 +01:00
parent 8b9fb63dcb
commit 9c27d1c861

View File

@ -14,7 +14,7 @@ use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest; use OCP\IRequest;
use OCP\IResponse; use OCP\IResponse;
use OCP\AppFramework\Http\JsonResponse; use OCP\AppFramework\Http\JSONResponse;
/** /**
* @psalm-suppress UnusedClass * @psalm-suppress UnusedClass
@ -33,22 +33,11 @@ class PageController extends Controller {
#[NoCSRFRequired] #[NoCSRFRequired]
#[NoAdminRequired] #[NoAdminRequired]
#[OpenAPI(OpenAPI::SCOPE_OPERATION, tags: ['post'])] #[FrontpageRoute(verb: 'POST', url: '/zipDeposit')]
#[FrontpageRoute(verb: 'POST', url: '/post')] public function post($archiveUrl, $token) {
public function post(): JsonResponse {
$request = $this->request; $request = $this->request;
$uploadedFile = $request->getUploadedFile('zipfile');
if (!$uploadedFile) {
return new JsonResponse(['error' => 'No file uploaded'], 400);
}
if ($uploadedFile->getClientMimeType() !== 'application/zip') {
return new JsonResponse(['error' => 'Invalid file type, only ZIP allowed'], 400);
}
// Traitement du fichier si nécessaire // Traitement du fichier si nécessaire
return new JsonResponse(['message' => 'File uploaded successfully'], 200); return new JsonResponse(['message' => 'File uploaded successfully' . $archiveUrl . " - " . $token], 200);
} }
} }