1.what does it mean by files.photo.path and files.photo.type??how to get access of type and path of user sent photo??
if(files.photo)//for photo & file.photo means user sent photo
{
product.photo.data=fs.readFileSync(files.photo.path)
product.photo.contentType=files.photo.type
}
//schema is-
const productSchema = new mongoose.Schema(
....
....
photo:{
data:Buffer,
contentType:String
},
....
....
},
{timestamps:true}
);
CodePudding user response:
Here files.photo.path
will give you the exact path of the respective file (where that respective file is located or stored)
and files.photo.type
will give you the content type of that particular file (the type of file it is - image, pdf, etc.)