const imagePath = "path/to/the/image.jpeg"; const imageData = fs.readFileSync(imagePath); const imageBuffer = Buffer.from(imageData); const imageBinary = new mongodb.Binary(imageBuffer); const imageMimeType = mime.lookup(imagePath); image = { name: i, contentType: imageMimeType, content: imageBinary } imagesData.push(image);