title: I'm trying to upload an image on mongodb using POSTMAN the error says,"Cannot read property 'buffer' of undefined"
body: <p>I am trying to post an image and 3 other fields to store in my mongoDB atlas, the following is the code in my ROUTES file</p>
  <pre><code>const express = require('express');
  const router = express.Router();
  const jwt = require('jsonwebtoken');
  const keys = require('../config/key');
  const passport = require('passport');
  const mongoose = require('mongoose');
  const { ensureAuth, ensureAdmin } = require('../middleware/auth');
  var multer = require('multer');
  
  var storage = multer.memoryStorage();
  var upload = multer({ storage: storage });
  
  // @route   POST /novels
  // @desc    Create novel
  // @access  Private
  router.post(
    '/',
    upload.single('image'),
  
    (req, res) =&gt; {
      const newNovel = new Novel({
        title: req.body.title,
        author: req.body.author,
        synopsis: req.body.synopsis,
      });
      newNovel.img.data = req.file.image.buffer;
      newNovel.img.contentType = 'image/jpg';
  
      console.log('boidy:', req.body);
  
      newNovel.save().then((novel) =&gt; res.json(novel));
    }
  );
  </code></pre>
  <p>The following things I enter in the postman body-part, the image contains error and entered field<a href="https://i.stack.imgur.com/wOD3S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wOD3S.png" alt="The postman image" /></a></p>
  <p>Here is my SCHEMA for the following</p>
  <pre><code>const mongoose = require('mongoose');
  const chapter = require('./Chapter');
  
  const NovelSchema = mongoose.Schema({
    title: {
      type: String,
      required: true,
    },
    author: {
      type: String, //mongoose.Schema.Types.ObjectId, // author object,
      required: true,
    },
    synopsis: {
      type: String,
      required: true,
    },
    comments: [
      {
        body: String,
        date: Date,
      },
    ],
    date: {
      type: Date,
      default: Date.now,
    },
    access: {
      // true for public || false for private
      type: Boolean,
      default: false,
    },
    noOfChapters: {
      type: Number,
    },
    ***img: { data: Buffer, contentType: String }***,
    Chapters: [
      {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Chapter',
      },
    ],
    genre: [String],
    meta: {
      views: {
        type: Number,
      },
      likes: {
        type: Number,
      },
    },
  });
  
  module.exports = Novel = mongoose.model('Novel', NovelSchema);
  </code></pre>
  <p>currently I am only adding TITLE,AUTHOR, and SYNOPSIS in my databse earlier I tried it without image and it worked just fine</p>