Skip to main content

Attachments: How to get attachment metadata only?

There are few methods that allow you to download attachment metadata from a database:

HeadAttachment

HeadAttachment can be used to download attachment metadata for a single attachment.

Syntax

Attachment HeadAttachment(string key);
Parameters
keystringkey of the attachment you want to download metadata for
Return Value
AttachmentObject 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
idPrefixstringprefix for which attachments should be returned
startintnumber of attachments that should be skipped
pageSizeintmaximum number of attachments that will be returned
Return Value
AttachmentInformationObject 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.