Managing attachments |
he documents may contain a custom field of type "file". The field itself does not contain attachment data. Only AttachmentGUID (unique identifier) value is stored in the document field referencing the record within separate table.
The attachments are stored in the table CMS_Attachment which contains the attachment metadata (file name, size, type, etc.) and optionally the attachment binary data (depending on where the files are stored). Attachment file may also be stored in the filesystem if the system is configured for storing files in the database. You can work with the attachments using the AttachmentManager class methods.
Here are some examples how to work with attachments:
Adding a new attachment to a document
To add a new attachment to a document, you need to save the attachment and store its GUID (unique identifier) to the document field.
[C#]
Removing an attachment from a document
To remove an existing attachment from a document, you need to delete the attachment and remove the document field reference to it. You should always remove the old attachment if you insert a new one.
[C#]
Please note: if you use workflow and versioning, see Versioning internals and the related chapters for more details how to work with attachments in the versioned documents.
|