complete addAttachment() method