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

217
Views
Cargar archivo usando multer y luego usarlo

Estoy cargando mi archivo usando multer, y luego estoy tratando de leer el archivo JSON y hacer algunas operaciones para él. Aparentemente, cuando tomo el nombre del archivo y lo paso a mi función, aparece el siguiente error: ingrese la descripción de la imagen aquí

El código dentro de mi app.js

 //UPLOAD FILE READER const storage = multer.diskStorage({ destination: (req, file, cb) => { cb(null, 'points') }, filename: (req, file, cb) => { const { originalname } = file; cb(null, originalname) } }) const upload = multer ({ storage }) //Function to get the name of the file for future use var splitTest = function (str) { return str.split('\\').pop().split('/').pop(); } app.post("/uploadFile",upload.single('fileupload'),(req, res, next) => { // Read File Before Uploading const absolutePath = path.join(__dirname, req.file.path); const jsonString = fs.readFileSync(absolutePath, "utf-8"); const jsonObject = JSON.parse(jsonString); nameFile = splitTest(absolutePath) //JSON SCHEMA VALIDATOR var innerSchema = schemas.jsonSchema; var innerArraySchema = { "type": "array", "items" : innerSchema } const ajv = new Ajv() const valid = ajv.validate(innerArraySchema, jsonObject) if (!valid) { fs.unlinkSync(req.file.path) res.redirect('admin') } else { console.log(nameFile) rFile(nameFile) res.redirect('admin') } })

También la función a la que llamo dentro de mi app.js.

 //Load JSON DATA to MySQL rFile("starting_pois.json") --> For testing its working perfectly function rFile(fileName) { fs.readFile(`../points/${fileName}`, 'utf-8', (err, jsonString) => { // Do stuff....
about 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!