Example code for mongodb http webhook function for uploading files

I am learning MongoDB Realm and trying to upload an image as formData, other input fields data have been injected successfully but image data is empty? Please provide me with the full code.
Here is my code:
exports = function (payload, response) {
var rent = {};
var result = {};

          if (payload.body) {
            rent = EJSON.parse(payload.body.text());

            console.log("parsed payload body", JSON.stringify(rent));

            const collection = context.services
              .get("mongodb-atlas")
              .db("apartmentData")
              .collection("hotels");

            return collection.insertOne(rent);
          }
          return result;
        };

Data in MongoDB Atlas:
image

Browser Console:
1. image1: FileList

  1. 0: File

    1. lastModified: 1620410950262
    2. lastModifiedDate: Sat May 08 2021 00:09:10 GMT+0600 (Bangladesh Standard Time) {}
    3. name: "3.PNG"
    4. size: 122103
    5. type: "image/png"
    6. webkitRelativePath: ""
    7. __proto__: File

Hi @Al_Fuad, welcome to the community forum!

As a first step, I’d suggest using the Realm SDK to invoke MongoDB Realm directly (rather than using Webhooks).

hi andrew, arent http webhooks designed to be called from a client application using axios or fetch or any xhr client? why use the sdk to make a simple ajax call?