A file attached to some other item, such as a comment or a blog post, holding the file's metadata and the hash used to fetch its content. The bytes themselves live in the blob store; this record only keeps the hash that locates them, along with the name, content type and size. The item it belongs to is referenced loosely by an itemId and itemType pair rather than a foreign key, so any feature can attach files without a schema change, and it also means nothing stops an attachment outliving the item it points at. Use the ordinal to control the display order of several attachments on one item.
Group: Database Entities
Implements: Serializable, Relational
Properties
| Property | Returns | Description |
|---|---|---|
| adminOrg | Organisation | The account, ie the top level administrative organisation, this attachment belongs to. Always set, and lookups are scoped by it so attachments cannot leak between accounts. |
| contentType | String | The MIME type of the file, for example application/pdf, as determined at upload time. |
| createdBy | Profile | The profile who uploaded the file. Can be null when the attachment was created outside a logged in session. |
| createdDate | Date | When the file was uploaded. |
| fileHash | String | The blob store hash of the file's content, which is how the actual bytes are located. Two attachments of the same content share a hash. |
| fileName | String | The name the file was uploaded with, used when offering it for download. Not unique and not path-safe. |
| fileSize | Long | The size of the file in bytes. |
| id | Long | The database-assigned unique identifier for this attachment. |
| itemId | Long | The id of the record this file is attached to. Only meaningful together with the item type, because ids are only unique within a table. |
| itemType | String | The kind of record this file is attached to, for example a comment or a blog post. This is a plain string agreed between the feature that stores the attachment and the one that reads it, not a validated class name. |
| notes | String | Free text description or caption entered for the file. Usually null. |
| ordinal | Integer | The sort position of this attachment among the files on the same item, used to control display order. Null when ordering has not been set. |
Methods
getId() · getFileName() · getFileHash() · getContentType() · getFileSize() · getNotes() · getOrdinal() · getItemId() · getItemType() · getCreatedDate() · getCreatedBy() · getAdminOrg() · rowId()
getId()
Returns: Long
The database-assigned unique identifier for this attachment.
getFileName()
Returns: String
The name the file was uploaded with, used when offering it for download. Not unique and not path-safe.
getFileHash()
Returns: String
The blob store hash of the file's content, which is how the actual bytes are located. Two attachments of the same content share a hash.
getContentType()
Returns: String
The MIME type of the file, for example application/pdf, as determined at upload time.
getFileSize()
Returns: Long
The size of the file in bytes.
getNotes()
Returns: String
Free text description or caption entered for the file. Usually null.
getOrdinal()
Returns: Integer
The sort position of this attachment among the files on the same item, used to control display order. Null when ordering has not been set.
getItemId()
Returns: Long
The id of the record this file is attached to. Only meaningful together with the item type, because ids are only unique within a table.
getItemType()
Returns: String
The kind of record this file is attached to, for example a comment or a blog post. This is a plain string agreed between the feature that stores the attachment and the one that reads it, not a validated class name.
getCreatedDate()
Returns: Date
When the file was uploaded.
getCreatedBy()
Returns: Profile
The profile who uploaded the file. Can be null when the attachment was created outside a logged in session.
getAdminOrg()
Returns: Organisation
The account, ie the top level administrative organisation, this attachment belongs to. Always set, and lookups are scoped by it so attachments cannot leak between accounts.
rowId()
Returns: Long
The database identifier for this attachment, as the generic row id used across Kademi entities. Same value as the id.