The create controller method in the media controller will use the formidable npm module to parse the multipart request body that will contain the media details and video file uploaded by the user:
npm install formidable --save
The media fields received in the form data, and parsed with formidable, will be used to generate a new Media object and saved to the database.
mern-mediastream/server/controllers/media.controller.js:
const create = (req, res, next) => { let form = new formidable.IncomingForm() form.keepExtensions = true form.parse(req, (err, fields, files) => { if (err) { return res.status(400).json({ error: "Video could not be uploaded" }) } let media = new Media(fields) media.postedBy= req.profile ...