Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1K
Views
MulterError: campo inesperado en el nodo js

Estoy tratando de guardar los múltiples campos de archivos en mongodb con el uso de multer, ya que estoy usando datos de formulario para seleccionar archivos. Según el archivo de campos de {name:'thumbnail'},{name:'trailer'},{name:'lessons'}] , estoy pasando lo mismo en el cartero pero muestra un error: MulterError: Unexpected field

Donde estoy pasando mal, por favor ayúdenme gracias de antemano

esquema:-

 mongoose.Schema( { category:{ type: String }, courseBy:{ type: String }, thumbnail: { type: String, data:Buffer}, about: { type: String }, price : { type: String }, is_free : { type:Boolean, default: false }, tags : { type: String }, comments : { type: String }, ratings : { type: String }, hours: { type : String }, trailerVideo : { title:{ type:String }, video: { type:String,data:Buffer }}, ratingCount : { type: Number}, lessons : [{ _id: false, title : { type:String }, video : { type:String,data:Buffer }, }] } )

creando un instante: -

 const trailer = { title: req.body.title, video: req.files.trailer[0].path, } const lessons = [{ title: req.body.title, video: req.files.lessons[0].path }] const { category, courseBy, about, price, hours } = req.body const courseFields = new Courses({ category: category, courseBy: courseBy, thumbnail: req.files.thumbnail[0].path, about: about, price: price, hours: hours, ratingCount : 0, ratings : 0.0, trailerVideo: trailer, lessons: lessons });

archivo multer

 const multer = require("multer"), storage = multer.diskStorage({ destination: function(req, file, cb) { cb(null, 'uploads') }, filename: function (req, file, cb) { cb(null, file.originalname); } }); const uploadImg = multer({storage: storage}).fields([{name:'thumbnail'},{name:'trailer'},{name:'lessons'}]);

ingrese la descripción de la imagen aquí

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!