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

322
Views
Espere a que se creen mis archivos. JS (carga rápida de archivos)

Express-fileupload tiene una función que permite mover el archivo .mv(), lo que busco es esperar a que termine para poder continuar con la siguiente tarea.

NPM: https://www.npmjs.com/package/express-fileupload

CÓDIGO

 console.log("Starting the loop") for (const element of _sources) { const file = req.files[element]; if (file !== undefined) { const _mime = mimesList.filter((v) => v.mimetype === file.mimetype); if (_mime.length === 0) { //... exec } else { console.log("Start moving the file") const previewPath = _path + new tokenGenerator().generate() + element + _mime[0].extension; await file.mv(previewPath, function (err) { if (err) { //!make error } req.files[element].preview = previewPath; console.log("No errors") }); console.log("I have finished moving the file.") } } else { //.. exec } } console.log("Ending the loop")

salida de corriente

 Starting the loop Start moving the file I have finished moving the file. Start moving the file I have finished moving the file. Start moving the file I have finished moving the file. Ending the loop No errors No errors No errors

Rendimiento esperado

 Starting the loop Start moving the file No errors I have finished moving the file. Start moving the file No errors I have finished moving the file. Start moving the file No errors I have finished moving the file. Ending the loop
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!