FIX: no se podia subir los videos

This commit is contained in:
2020-06-18 02:16:32 -04:00
parent 0f26b53546
commit ef453fef56
9 changed files with 317 additions and 79 deletions

View File

@ -123,4 +123,38 @@ class Eventos {
->withHeader('Content-Type', 'application/json')
->withStatus(201);
}
public function addVideo(Request $request, Response $response, Container $container, DataHandler $handler, MediaLoader $loader, $evento): Response {
$post = $request->getParsedBody();
$files = $request->getUploadedFiles();
if (count($files) == 0) {
$output = [
'informacion' => '',
'evento' => $evento,
'estado' => false
];
$response->getBody()->write(json_encode($output));
return $response->withHeader('Location', implode('/', [
$container->get('urls')['admin'],
'evento',
$evento
]));
}
$file = $files['video'];
$eventos = $handler->load('eventos');
$e = $eventos[$evento];
if (is_array($file)) {
$status = false;
foreach ($file as $f) {
$status |= $loader->add($e, $f);
}
} else {
$status = $loader->add($e, $file);
}
$response->getBody()->write(json_encode($output));
return $response->withHeader('Location', implode('/', [
$container->get('urls')['admin'],
'evento',
$evento
]));
}
}