Read filename from content-disposition header when downloading files

Describe the issue/error/question

I send a pdf file to an OCR API endpoint. Afterwards I receive the scanned file in field “ocr_file”.

Also in the JSON view you can find the header "
“attachment; filename=**********.PDF”,

How I can set the filename from the header to the PDF file?

Currently I use the code node with the following code to get the fileName before sending it to HTTP node and rename the ocr_file, so i would need to get the filename from the header of the HTTP node.

Please share the workflow

Information on your n8n setup

  • n8n version: latest
  • Database you’re using (default: SQLite): SQLite
  • Running n8n with the execution process [own(default), main]: default
  • Running n8n via [Docker, npm,, desktop app]: Docker

Hi @philippkayser, this is a known limitation I am afraid. n8n does not respect this header when downloading a file using the HTTP Request node.

You might want to leave a vote on the corresponding feature request:

I have also provided a workaround in the feature request (using the older Function Item node since the Code node wasn’t a thing back then, but it should still work).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

New version [email protected] got released which includes the GitHub PR 7032.