diff --git a/plugins/attachment-resources/src/components/AttachmentPopup.svelte b/plugins/attachment-resources/src/components/AttachmentPopup.svelte index 7f7073ac8d..6c17b87ec5 100644 --- a/plugins/attachment-resources/src/components/AttachmentPopup.svelte +++ b/plugins/attachment-resources/src/components/AttachmentPopup.svelte @@ -18,7 +18,7 @@ import { createQuery, getClient, getFileMetadata, uploadFile } from '@hcengineering/presentation' import { ActionIcon, IconAdd, Label, Loading } from '@hcengineering/ui' - import type { Doc, WithLookup } from '@hcengineering/core' + import core, { Doc, Ref, Space, WithLookup } from '@hcengineering/core' import { setPlatformStatus, unknownError } from '@hcengineering/platform' import { AttachmentPresenter } from '..' @@ -59,8 +59,11 @@ try { const uuid = await uploadFile(file) const metadata = await getFileMetadata(file, uuid) + const space = client.getHierarchy().isDerived(object._class, core.class.Space) + ? (object._id as Ref) + : object.space - await client.addCollection(attachment.class.Attachment, object.space, object._id, object._class, 'attachments', { + await client.addCollection(attachment.class.Attachment, space, object._id, object._class, 'attachments', { name: file.name, file: uuid, type: file.type, diff --git a/plugins/attachment-resources/src/components/AttachmentStyleBoxCollabEditor.svelte b/plugins/attachment-resources/src/components/AttachmentStyleBoxCollabEditor.svelte index c3a7592656..85a28236e5 100644 --- a/plugins/attachment-resources/src/components/AttachmentStyleBoxCollabEditor.svelte +++ b/plugins/attachment-resources/src/components/AttachmentStyleBoxCollabEditor.svelte @@ -15,7 +15,7 @@