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

492
Views
Is it possible to use the sendFile response method in node + express to send to the client multiple images?

I'm trying to loop trough all files of an image directory, but when i access the route from the client the images cross each other and i get this error:

RangeNotSatisfiableError: Range Not Satisfiable
    at SendStream.error (C:\Users\myuser\Desktop\Javascript Projects\myproject\node_modules\send\index.js:270:31)
    at SendStream.send (C:\Users\myuser\Desktop\Javascript Projects\myproject\node_modules\send\index.js:670:19)
    at onstat (C:\Users\myuser\Desktop\Javascript Projects\myproject\node_modules\send\index.js:729:10)
    at FSReqCallback.oncomplete (node:fs:199:5)
Error: Can't set headers after they are sent.
    at SendStream.headersAlreadySent (C:\Users\Utente-XB\Desktop\Javascript Projects\myproject\node_modules\send\index.js:390:13)
    at SendStream.send (C:\Users\myuser\Desktop\Javascript Projects\myproject\node_modules\send\index.js:617:10)
    at onstat (C:\Users\myuser\Desktop\Javascript Projects\myproject\node_modules\send\index.js:729:10)
    at FSReqCallback.oncomplete (node:fs:199:5)
app.get(`/${SECRET_IMAGES_LOCATION}`, (req, res) => {
    fs.readdir(path.join(__dirname, "/img"), (err, files) => {
        if (err) return console.log(`Unable to open dir: `, err)
        
        files.forEach(file => {
            res.sendFile(path.join(__dirname, `/img/${file}`))
        })
    })
})
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No, you can send only a single file per HTTP request. It is the HTTP protocol. You access one URL and you receive one image.

about 4 years ago · Juan Pablo Isaza 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!