Add function to get attachments

Attachment support is added recently, but there is no way to get the attachment. This patch adds a convenience function to get an attachment for a document