InstructorLiceseDetails is a nested array name in which each object contains LicenseImage with file detail i am unnable to send binary it in formData like how i mentioned in multer
this is how i am sending from frontend this only receive ProfileImage and TRainerPermitImage
const InstructorFormData = new FormData();
let InstructorDataNoImage = {};
for (let [key, value] of Object.entries(InstructorData)) {
console.log("key:", key, "value:", value);
if (key.indexOf("Image") > -1) {
InstructorFormData.append(key, value);
} else
InstructorDataNoImage = { ...InstructorDataNoImage, [key]: value };
}
export const MulterFor_InstructorImages = (req, res, next) => {
console.log("MulterFor_InstructorImages Reqbody", req.body);
let MulterVals = {};
MulterVals.filepath = "./Public/Institute/Instructors";
MulterVals.UploadFields = [
{ name: "ProfileImage" },
{ name: "TrainerPermitImage" },
...(req.body.InstructorLicenseDetails || []).map((license, index) => ({
name: `LicenseImage_${index + 1}`,
})),
...(req.body.SpecialLicenseDetails || []).map((license, index) => ({
name: `SLicenseImage_${index + 1}`,
})),
];
MulterVals.filetypes = [];
MulterVals.filetypes[0] = "image/png";
MulterVals.filetypes[1] = "image/jpg";
MulterVals.filetypes[2] = "image/jpeg";
MulterVals.filetypes[3] = "image/svg+xml";
MulterMiddleware(req, res, next, MulterVals);
};
now how to send nested array images dynamically field name as i given in multer