refs https://github.com/firebaseco/mongoose-attachments/issues/15 : cherry picked https://github.com/joewright/mongoose-attachments/commit/65b4ba6698f0686b5e0f4e241bf94e31b12ccc8f for https://github.com/firebaseco/mongoose-attachments/issues/11