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

664
Views
¿Cómo validar diferentes tipos de archivos en multer s3?

Quiero manejar y validar archivos de video e imagen de multer. El middleware Multer puede tener 1 archivo de video y 10 imágenes. Quiero validar si tiene solo 10 imágenes y 1 archivo de video. También quiero validar el tamaño del archivo. tener 25 mb y las imágenes para tener 5 mb. Pero las opciones de límites solo toman un tamaño de archivo. Aquí se valida para un archivo de 5 mb. ¿Cómo valido el video, que debe ser de 25 mb?

 const multerS3 = require('multer-s3'); const multer = require('multer'); const AWS = require('aws-sdk'); const s3 = new AWS.S3({ accessKeyId: process.env.ACCESS_KEY_ID, secretAccessKey: process.env.SECRET_ACCESS_KEY, region: process.env.REGION }); const fileFilter = (req, file, cb) => { console.log(file.mimetype); if (file.mimetype === 'image/jpeg' || file.mimetype === 'image/png') { cb(null, true); } else { cb(null, false); } cb(null, true); }; const middleware = function(req, res, next) { let upload = multer({ storage: multerS3({ s3: s3, bucket: process.env.BUCKET_NAME, acl: 'public-read', cacheControl: 'max-age=31536000', contentType: multerS3.AUTO_CONTENT_TYPE, metadata: function(req, file, cb) { // console.log('in callback'); cb(null, { fieldName: file.fieldname }); }, key: function(req, file, cb) { // console.log('in callback 2'); cb(null, Date.now().toString() + '-' + file.originalname); } }), fileFilter: fileFilter, limits: { fileSize: 1024 * 1024 * 5 } }).fields([ { name: 'images', maxCount: 10 }, { name: 'video', maxCount: 1 } ]); upload(req, res, function(err) { console.log(err); next(); }); }; module.exports = middleware;

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Actualmente, no es compatible con multer,

Puede seguir la discusión en GitHub para obtener más detalles:

problema-569 ,
problema-833 ,
problema-314

over 4 years ago · Santiago Trujillo Report
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!