Skip to content

Commit 99fa512

Browse files
committed
Return all failures
1 parent d9dfd5f commit 99fa512

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

src/Controllers/Files.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php namespace Tatter\Files\Controllers;
22

33
use CodeIgniter\Controller;
4+
use CodeIgniter\Events\Events;
5+
use CodeIgniter\HTTP\Exceptions\HTTPException;
46
use CodeIgniter\HTTP\RedirectResponse;
57
use CodeIgniter\HTTP\RequestInterface;
68
use CodeIgniter\HTTP\ResponseInterface;
@@ -409,11 +411,19 @@ public function upload()
409411
$chunkDir = WRITEPATH . 'uploads/' . $uuid;
410412
if (! is_dir($chunkDir) && ! mkdir($chunkDir, 0775, true))
411413
{
412-
throw FilesException::forChunkDirFail($chunkDir);
414+
return $this->failure(400, lang('Files.chunkDirFail', [$chunkDir]));
413415
}
414416

415417
// Move the file
416-
$upload->move($chunkDir, $chunkIndex . '.' . $upload->getExtension());
418+
try
419+
{
420+
$upload->move($chunkDir, $chunkIndex . '.' . $upload->getExtension());
421+
}
422+
catch (HTTPException $e)
423+
{
424+
log_message('error', $e->getMessage());
425+
return $this->failure(400, $e->getMessage());
426+
}
417427

418428
// Check for more chunks
419429
if ($chunkIndex < $totalChunks - 1)
@@ -423,7 +433,15 @@ public function upload()
423433
}
424434

425435
// Merge the chunks
426-
$path = $this->mergeChunks($chunkDir);
436+
try
437+
{
438+
$path = $this->mergeChunks($chunkDir);
439+
}
440+
catch (FilesException $e)
441+
{
442+
log_message('error', $e->getMessage());
443+
return $this->failure(400, $e->getMessage());
444+
}
427445
}
428446

429447
// Get additional post data to pass to model

0 commit comments

Comments
 (0)