Commit 516a46e5 authored by François Agneray's avatar François Agneray
Browse files

Anis-server data_path for dataset download file

parent 9df09d0f
......@@ -190,5 +190,5 @@ $container->set('App\Action\SearchAction', function (ContainerInterface $c) {
});
$container->set('App\Action\DownloadFileAction', function (ContainerInterface $c) {
return new App\Action\DownloadFileAction($c->get('em'), $c->get(SETTINGS)['token']);
return new App\Action\DownloadFileAction($c->get('em'), $c->get('settings')['data_path'], $c->get(SETTINGS)['token']);
});
......@@ -30,7 +30,7 @@ final class AdminFileExplorerAction
/**
* Create the classe before call __invoke to execute the action
*
* @param string $dataPath Contains anis-server data path
* @param string $dataPath Contains anis-server data path
*/
public function __construct(string $dataPath)
{
......
......@@ -20,6 +20,13 @@ use Nyholm\Psr7\Factory\Psr17Factory;
final class DownloadFileAction extends AbstractAction
{
/**
* Contains anis-server data path
*
* @var string
*/
private $dataPath;
/**
* Contains settings to handle Json Web Token
*
......@@ -30,12 +37,14 @@ final class DownloadFileAction extends AbstractAction
/**
* Create the classe before call __invoke to execute the action
*
* @param EntityManagerInterface $em Doctrine Entity Manager Interface
* @param array $settings Settings about token
* @param EntityManagerInterface $em Doctrine Entity Manager Interface
* @param string $dataPath Contains anis-server data path
* @param array $settings Settings about token
*/
public function __construct(EntityManagerInterface $em, array $settings)
public function __construct(EntityManagerInterface $em, string $dataPath, array $settings)
{
parent::__construct($em);
$this->dataPath = $dataPath;
$this->settings = $settings;
}
......@@ -71,7 +80,7 @@ final class DownloadFileAction extends AbstractAction
}
// Search the file
$filePath = realpath($dataset->getDataPath()) . DIRECTORY_SEPARATOR . $args['fpath'];
$filePath = $this->dataPath . $dataset->getDataPath() . DIRECTORY_SEPARATOR . $args['fpath'];
// If the file not found 404
if (!file_exists($filePath)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment