Photo management and various fixes.
CI / Docker Lint (push) Failing after 23s

- Added admin page to upload and manage media.
- Fixed /setup route.
- Updated dockerfiles to support admin media.
- Improved deploy docs.
This commit is contained in:
2024-09-14 20:53:35 +02:00
parent f1031c14df
commit ee058aa3b3
14 changed files with 452 additions and 9 deletions
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace App\Service;
use Symfony\Component\HttpFoundation\File\Exception\FileException;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\String\Slugger\SluggerInterface;
class FileUploaderService
{
public function __construct(
private string $targetDirectory,
private SluggerInterface $slugger,
) {}
public function upload(UploadedFile $file): string
{
$originalFilename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
$safeFilename = $this->slugger->slug($originalFilename);
$fileName = $safeFilename . '-' . uniqid() . '.' . $file->guessExtension();
try {
$file->move($this->getTargetDirectory(), $fileName);
} catch (FileException $e) {
// ... handle exception if something happens during file upload
}
return $fileName;
}
public function deleteFile(string $filepath): bool
{
if (!$filepath || !is_file($filepath)) {
return false;
}
$deleted = unlink($filepath);
return $deleted;
}
public function getTargetDirectory(): string
{
return $this->targetDirectory;
}
}