feat: organize uploads into subfolders
This commit is contained in:
@@ -10,6 +10,7 @@ use Oneup\UploaderBundle\Uploader\Orphanage\OrphanageManager;
|
|||||||
use Symfony\Component\Filesystem\Exception\IOException;
|
use Symfony\Component\Filesystem\Exception\IOException;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
use function Symfony\Component\String\s;
|
||||||
|
|
||||||
class UploadHandler
|
class UploadHandler
|
||||||
{
|
{
|
||||||
@@ -119,7 +120,9 @@ class UploadHandler
|
|||||||
|
|
||||||
public function getUploadFilepath(Upload $upload): string
|
public function getUploadFilepath(Upload $upload): string
|
||||||
{
|
{
|
||||||
return sprintf('%s/uploads/%s/%s', $this->projectDir, $upload->getType(), $upload->getFilename());
|
$folder = substr($upload->getFilename(), 0, 1);
|
||||||
|
|
||||||
|
return sprintf('%s/uploads/%s/%s/%s', $this->projectDir, $upload->getType(), $folder, $upload->getFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTempUploadFilepath(UploadDto $uploadDto, string $uploadSessionId): string
|
public function getTempUploadFilepath(UploadDto $uploadDto, string $uploadSessionId): string
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ class UploadNamer implements NamerInterface
|
|||||||
{
|
{
|
||||||
public function name(FileInterface $file): string
|
public function name(FileInterface $file): string
|
||||||
{
|
{
|
||||||
return sprintf('%s.%s', Uuid::v4(), strtolower($file->getExtension()));
|
$fileUuid = Uuid::v7();
|
||||||
|
$folder = substr($fileUuid, 0, 1);
|
||||||
|
|
||||||
|
return sprintf('%s/%s.%s', $folder, $fileUuid, strtolower($file->getExtension()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
{{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }}
|
{{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }}
|
||||||
<a href="{{ path('app_common_download', { 'uuid': document.uuid, 'inline': true }) }}"
|
<a href="{{ path('app_common_download', { 'uuid': document.uuid, 'inline': true }) }}"
|
||||||
|
target="_blank"
|
||||||
class="flex justify-between items-center pb-4"
|
class="flex justify-between items-center pb-4"
|
||||||
title="Dokument öffnen">
|
title="Dokument öffnen">
|
||||||
<h2 class="font-bold text-lg">
|
<h2 class="font-bold text-lg">
|
||||||
|
|||||||
Reference in New Issue
Block a user