Skip to content

Commit c3dc792

Browse files
committed
TASK: Set upload directorxy path
1 parent d7dbfca commit c3dc792

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

Classes/Controller/MediaController.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818
use Flowpack\Media\Ui\Tus\TusEventHandler;
1919
use Neos\Cache\Frontend\VariableFrontend;
2020
use Neos\Flow\Annotations as Flow;
21+
use Neos\Flow\Utility\Environment;
22+
use Neos\Flow\Utility\Exception;
2123
use Neos\Fusion\View\FusionView;
2224
use Neos\Neos\Controller\Module\AbstractModuleController;
25+
use Neos\Utility\Exception\FilesException;
26+
use Neos\Utility\Files;
27+
use ReflectionException;
2328
use TusPhp\Events\TusEvent;
2429
use TusPhp\Tus\Server;
2530

@@ -34,6 +39,12 @@ class MediaController extends AbstractModuleController
3439
*/
3540
protected $tusEventHandler;
3641

42+
/**
43+
* @Flow\Inject
44+
* @var Environment
45+
*/
46+
protected $environment;
47+
3748
/**
3849
* @var FusionView
3950
*/
@@ -65,11 +76,20 @@ public function indexAction(): void
6576
}
6677

6778
/**
68-
* @throws \ReflectionException
79+
* @throws Exception
80+
* @throws FilesException
81+
* @throws ReflectionException
6982
*/
7083
public function uploadAction(): void
7184
{
85+
$uploadDirectory = Files::concatenatePaths([$this->environment->getPathToTemporaryDirectory(), 'TusUpload']);
86+
if (!file_exists($uploadDirectory)) {
87+
Files::createDirectoryRecursively($uploadDirectory);
88+
}
89+
7290
$server = new Server($this->partialUploadFileCacheAdapater);
91+
$server->setApiPath($this->controllerContext->getRequest()->getHttpRequest()->getUri()->getPath())
92+
->setUploadDir($uploadDirectory);
7393
// @todo: Set upload dir to data/temporary
7494

7595
$server->event()->addListener('tus-server.upload.complete', function (TusEvent $event) {

0 commit comments

Comments
 (0)