ibrod83 / nodejs-file-downloader

130 stars 23 forks source link

content-disposition with filename* not working #44

Open richywalls opened 1 year ago

richywalls commented 1 year ago

Hi, Just a recommendation, maybe use for filename detection the module https://github.com/jshttp/content-disposition, a current fix is using the event onResponse and replacing the header.

onResponse(response) {
  const disp = contentDisposition.parse(response.headers['content-disposition'])
  response.headers['content-disposition'] = contentDisposition(disp.parameters.filename, {
    type: disp.type
  })
}

but this won't allways work ( ie, when there is an encoding used, it will give the same content-disposition header )

Maybe use the module in this part? https://github.com/ibrod83/nodejs-file-downloader/blob/4b0b0e8854d6534bf92563bb52b5f9818a286ad8/utils/fileName.js#L72-L84

thanks

ibrod83 commented 1 year ago

Maybe a small logical fix into my code will fix it? Can you maybe take a look and add it?