You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * @typedef {object} UserPhotoUploadRequest * @property {string} field1 - some field 1 * @property {integer} field2 - some field 2 * @property {string} photo.required - Photo - binary *//** * POST /photo * @summary Uploads use photo * @param {UserPhotoUploadRequest} request.body.required - request body - multipart/form-data * @returns {boolean} 200 - success * @returns {string} 400 - error text * @returns {string} 500 - error text */router.post('/photo',validateRequest(),async(req,res)=>{try{constform=newmultiparty.Form();form.parse(req,async(err,fields,files)=>{// here we get an error since req object is already read by the validateRequest()// also we have no way to access parsed fields and files by the validateRequest() call});}catch(err){res.status(500).send(err.message);}}
This happens since multiparty reads the req object stream. A possible solution is to modify the request object inside the validateRequest() call by adding fields and files properties there.
The text was updated successfully, but these errors were encountered:
This happens since multiparty reads the req object stream. A possible solution is to modify the request object inside the validateRequest() call by adding fields and files properties there.
The text was updated successfully, but these errors were encountered: