Added permission handling for attachments