Download File HTTP Request

Hi, I download a file (image) via HTTP request.

The problem now is that the file name has an extension because it is not recognized as an image. How can I rename the file or build the HTTP request so that it downloads it as an image

Can someone help me ?

You can for example fix it with a Code-Node and the following code:

for (const item of $input.all()) { = 'image/png'; = 'whatever.png';

return $input.all();

I hope that is helpful!

HI, thanks.
Where does the code in the HTTP Request module go?

Hi @mac338, this snippet would have to be executed after the HTTP Request in a separate Code node.

On a separate note, it might be worth checking if your server is sending the file name in a content-disposition header. This header is currently ignored by n8n, but might provide the “real” filename. You could read it like so:

If your server sends such a header, you might want to leave a vote on the corresponding feature request (so we might see support for this right in the HTTP Request node in the future): HTTP Request Node: Read filename from content-disposition header when downloading files

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