title: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'buffer' of undefined
body: <p>I am struggling to upload an image to mongodb from react native. I am getting the above error.I am able to upload the images via postman. Below is the the NodeJS route handling photo uploads</p>
  <pre><code>router.post(
    &quot;/users/profile/photo&quot;,
    auth,
    upload.single(&quot;profilePhoto&quot;),
    async (req, res) =&gt; {
      console.log(req);
      const buffer = await sharp(req.file.buffer)
        .resize({ width: 250, height: 250 })
        .png()
        .toBuffer();
  
      req.user.profile_photo = buffer;
      await req.user.save();
      res.send();
    },
    (error, req, res, next) =&gt; {
      res.status(400).send({ error: error.message });
    }
  );
  </code></pre>
  <p>This the code from react native</p>
  <pre><code>const profilePhoto = userData.images[0].replace(&quot;file:/&quot;, &quot;&quot;);
  
      if (profilePhoto.length !== 0) {
        const data = new FormData();
        data.append(&quot;profilePhoto&quot;, profilePhoto);
        const res = await userApi.uploadProfilePhoto(data);
        if (!res.ok) {
          console.log(res);
          alert(res.data.error);
          return;
        }
      }
  </code></pre>
  <p><strong>Upload function</strong></p>
  <pre><code>const uploadProfilePhoto = (photo) =&gt;
    client.post(`${usersEndpoint}/profile/photo`, photo, {
      &quot;Content-Type&quot;: &quot;multipart/form-data; &quot;,
    });
  </code></pre>
  <p>Could anyone help me troubleshoot what i am doing wrong here</p>
  <p><strong>EDIT</strong>
  I am adding part of request from past that does not exit on request from react native</p>
  <pre><code>file: {
      fieldname: 'profilePhoto',
      originalname: 'profile-pic.jpg',
      encoding: '7bit',
      mimetype: 'image/jpeg',
      buffer: &lt;Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 48 00 48 00 00 ff e1 00 8c 45 78 69 66 00 00 4d 4d 00 2a 00 00 00 08 00 05 01 12 00 03 00 00 00 01 00 01 ... 223959 more bytes&gt;,
      size: 224009
    },
  </code></pre>
  <p><strong>The code from Postman</strong></p>
  <pre><code>var axios = require('axios');
  var FormData = require('form-data');
  var fs = require('fs');
  var data = new FormData();
  data.append('profilePhoto', fs.createReadStream('/C:/Users/user/Downloads/node-course-images/node-course-images/profile-pic.jpg'));
  
  var config = {
    method: 'post',
    url: '127.0.0.1:3000/users/profile/photo',
    headers: { 
      'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDA1YmQ0NzkyYTQ1ZDU0ZjA1Y2MwYjUiLCJzdXBlcnVzZXIiOnRydWUsInJvbGUiOiJhZG1pbiIsIm5hbWUiOiJQYXVsIE11dGVzaGkiLCJlbWFpbCI6InN1cGVyQGdtYTlsLmNvbSIsInBob25lIjoiMDcyMjMwNDIyMyIsImlhdCI6MTYxMTk0Mzc2N30.c633qRqz-kQ00duMMJTZzW14hWsLf2Tt6nya_tWfWEY', 
      ...data.getHeaders()
    },
    data : data
  };
  
  axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });
  
  </code></pre>