BookStack\Services\AttachmentService::saveUpdatedUpload PHP Method

saveUpdatedUpload() public method

Store a upload, saving to a file and deleting any existing uploads attached to that file.
public saveUpdatedUpload ( Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile, Attachment $attachment ) : Attachment
$uploadedFile Symfony\Component\HttpFoundation\File\UploadedFile
$attachment BookStack\Attachment
return BookStack\Attachment
    public function saveUpdatedUpload(UploadedFile $uploadedFile, Attachment $attachment)
    {
        if (!$attachment->external) {
            $this->deleteFileInStorage($attachment);
        }
        $attachmentName = $uploadedFile->getClientOriginalName();
        $attachmentPath = $this->putFileInStorage($attachmentName, $uploadedFile);
        $attachment->name = $attachmentName;
        $attachment->path = $attachmentPath;
        $attachment->external = false;
        $attachment->extension = $uploadedFile->getClientOriginalExtension();
        $attachment->save();
        return $attachment;
    }