feat(attachments): update filename generation in AttachmentService to include file extension
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user