debut page post
This commit is contained in:
parent
2ac5b8e2ec
commit
8b9fb63dcb
@ -2,5 +2,6 @@
|
|||||||
return [
|
return [
|
||||||
'routes' => [
|
'routes' => [
|
||||||
['name' => 'page#main', 'url' => '/', 'verb' => 'GET'],
|
['name' => 'page#main', 'url' => '/', 'verb' => 'GET'],
|
||||||
|
['name' => 'page#post', 'url' => '/post', 'verb' => 'POST'],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
@ -11,6 +11,10 @@ use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
|||||||
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||||
use OCP\AppFramework\Http\Attribute\OpenAPI;
|
use OCP\AppFramework\Http\Attribute\OpenAPI;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
|
use OCP\IRequest;
|
||||||
|
use OCP\IResponse;
|
||||||
|
use OCP\AppFramework\Http\JsonResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @psalm-suppress UnusedClass
|
* @psalm-suppress UnusedClass
|
||||||
@ -26,4 +30,25 @@ class PageController extends Controller {
|
|||||||
'index',
|
'index',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[NoCSRFRequired]
|
||||||
|
#[NoAdminRequired]
|
||||||
|
#[OpenAPI(OpenAPI::SCOPE_OPERATION, tags: ['post'])]
|
||||||
|
#[FrontpageRoute(verb: 'POST', url: '/post')]
|
||||||
|
public function post(): JsonResponse {
|
||||||
|
$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
|
||||||
|
return new JsonResponse(['message' => 'File uploaded successfully'], 200);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user