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:
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