mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: carry out mime-type guessing on incoming attachments
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user