1

I've tried multiple solutions coming from: How to download a file with Node.js (without using third-party libraries)?

I have the following path related error:

internal/streams/legacy.js:57
      throw er; // Unhandled stream error in pipe.
      ^

Error: ENOENT: no such file or directory, open 'bot_side/img/image.jpg'

My app structure looks like this: enter image description here

My code is the following:

download(url, path, () => {
      return imageClassification(path)
})

const download = (url, path, callback) => {
  request.head(url, (err, res, body) => {
    request(url)
      .pipe(fs.createWriteStream(path))
      .on('close', callback)
  })
}

Thanks.

cyruslk
  • 839
  • 3
  • 13
  • 25

0 Answers0