Attachments: How to get attachment metadata only?
There are few methods that allow you to download attachment metadata from a database:
- HeadAttachment
- GetAttachmentHeadersStartingWith
HeadAttachment
HeadAttachment can be used to download attachment metadata for a single attachment.
Syntax
Attachment HeadAttachment(string key);
Parameters | ||
---|---|---|
key | string | key of the attachment you want to download metadata for |
Return Value | |
---|---|
Attachment | Object that represents attachment. |
Example
Attachment attachment = store
.DatabaseCommands
.HeadAttachment("albums/holidays/sea.jpg"); // null if does not exist
GetAttachmentHeadersStartingWith
GetAttachmentHeadersStartingWith can be used to download attachment metadata for a multiple attachments.
Syntax
IEnumerable<Attachment> GetAttachmentHeadersStartingWith(
string idPrefix,
int start,
int pageSize);
Parameters | ||
---|---|---|
idPrefix | string | prefix for which attachments should be returned |
start | int | number of attachments that should be skipped |
pageSize | int | maximum number of attachments that will be returned |
Return Value | |
---|---|
AttachmentInformation | Object that represents attachment metadata information. |
Example
IEnumerable<Attachment> attachments = store
.DatabaseCommands
.GetAttachmentHeadersStartingWith("albums/holidays/", 0, 10);
Remarks
Data property in Attachment
will return empty stream for the above methods.