attachments middleware