KAZOO-2875: handle attachments by extension if required

Imported the patch as provided by Sergey Korobkov on the Jira ticket, thanks!