feat(attachments): update filename generation in AttachmentService to include file extension

This commit is contained in:
2026-06-25 15:43:31 -03:00
parent e4448d810e
commit 17799122e2

View File

@@ -32,7 +32,7 @@ class AttachmentService
$storedPath = Storage::disk('s3')->putFileAs(
$this->directoryFromPath($normalizedPath),
$file,
$key,
$this->buildStoredFilename($key, $file),
);
if (! is_string($storedPath) || $storedPath === '') {
@@ -120,4 +120,15 @@ class AttachmentService
return AttachmentType::Other;
}
protected function buildStoredFilename(string $key, UploadedFile $file): string
{
$extension = strtolower($file->getClientOriginalExtension() ?: $file->extension() ?: '');
if ($extension === '') {
return $key;
}
return $key.'.'.$extension;
}
}