Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
height: 1,
},
};
if (imageId) {
console.log('Updating previous image upload', attributes);
Images.update({ _id: imageId }, { $set: attributes });
} else {
console.log('Inserting image upload', attributes);
imageId = Images.insert(attributes);
}
// get updated image data
const image = Images.findOne(imageId);
const mimeTypeDetector = new FileType();
const imageSizeDetector = new ImageSize();
imageStream.pipe(mimeTypeDetector);
mimeTypeDetector.on('file-type', (fileType) => {
const unsupportedFileType =
fileType === null || !allowedMimeTypes.includes(fileType.mime.toLowerCase());
if (unsupportedFileType) {
callback(new Meteor.Error(415, `Unsupported file-type detected (${fileType ? fileType.mime : 'unknown'}).`));
imageStream.emit('error');
}
const mismatchedFileType =
mimeType && fileType && mimeType.toLowerCase() !== fileType.mime.toLowerCase();
if (mismatchedFileType) {
callback(new Meteor.Error(415, `File-type (${fileType.mime}) does not match specified mime-type (${mimeType}).`));
imageStream.emit('error');