fix: carry out mime-type guessing on incoming attachments

This commit is contained in:
Julian Lam
2024-09-17 14:18:16 -04:00
parent d0ac5ff99f
commit 71ce308936

View File

@@ -2,6 +2,7 @@
const crypto = require('crypto');
const _ = require('lodash');
const mime = require('mime');
const db = require('../database');
@@ -50,6 +51,11 @@ Attachments.update = async (pid, attachments) => {
_type = 'attachment';
}
if (!mediaType) { // MIME type guessing
const { pathname } = new URL(url);
mediaType = mime.getType(pathname);
}
bulkOps.hash.push([key, { _type, mediaType, url, name, width, height }]);
hashes.push(hash);
});