mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-09 10:22:51 +03:00
Attachment API: Fixed error when name not provided in update
Fixes #5353
This commit is contained in:
@@ -116,16 +116,18 @@ class AttachmentService
|
||||
*/
|
||||
public function updateFile(Attachment $attachment, array $requestData): Attachment
|
||||
{
|
||||
$attachment->name = $requestData['name'];
|
||||
$link = trim($requestData['link'] ?? '');
|
||||
if (isset($requestData['name'])) {
|
||||
$attachment->name = $requestData['name'];
|
||||
}
|
||||
|
||||
$link = trim($requestData['link'] ?? '');
|
||||
if (!empty($link)) {
|
||||
if (!$attachment->external) {
|
||||
$this->deleteFileInStorage($attachment);
|
||||
$attachment->external = true;
|
||||
$attachment->extension = '';
|
||||
}
|
||||
$attachment->path = $requestData['link'];
|
||||
$attachment->path = $link;
|
||||
}
|
||||
|
||||
$attachment->save();
|
||||
|
Reference in New Issue
Block a user