FileUpload dynamic directory issue

I've build a Fileupload Helper like so to be reusable across resources:

class FileUploadHelper
{
    /**
     * Create a standardized file upload component
     *
     * @param bool   $required
     */
    public static function createFileUpload(
        string $name,
        string $label,
        string $directoryName,
        string $prefix,
        string $dbColumn,
        string $subdirectory,
        array $options): FileUpload
    {
        $upload = FileUpload::make($name)
            ->label(__($label))
            ->directory(
                fn (Get $get): string => $directoryName . '/'
                    . ($get('prefix') ?? $prefix . '#' . str_pad((string)$get($dbColumn), 4, '0', STR_PAD_LEFT))
                    . '/'
                    . $subdirectory
            )
            ->openable();

            // Options
            if (isset($options['hiddenLabel']) ?? false) {
                $upload->hiddenLabel();
            }

            // Some more ...

            return $upload;
    }
}


it's working like charm, here is how it is used in the resource:

FileUploadHelper::createFileUpload(
    name: 'accident_images',
    label: 'Accident Images',
    directoryName: 'Accidents',
    prefix: 'MVA',
    dbColumn: 'ac_number',
    subdirectory: 'Accident Images',
    options: [
        'required' => true,
        'image' => true,
        'multiple' => true,
        'maxFiles' => 20,
        'imagePreviewHeight' => 250,
        'panelLayout' => 'grid',
        'hint' => "Make sure the files are in any image format (jpg, jpeg, png, webp, gif)",
        'hintColor' => 'primary',
    ]
),


In short, each accident has a reference number (MVA#0000). The files are uploaded correctly to the dynamic folders. but when I access the edit/view page of the record, the images are not showing, and when trying to access them though url I get 404 not found (see attached).

May you please assist me with solving/tracing this?
Thank you
image.png
Was this page helpful?