How to create download link with file name

Hey guys,

I’m trying to create a link to download a stack.yml, but it’s not downloading with the file name, what can I do?

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

@htnrodrigues , if you add /stack.yaml to the webhook’s path then the file downloaded will be named stack.yaml.

In other words, the resource you want to GET has to be registered with the API.

1 Like

Hey @ihortom,

What if the file name needs to be different for each stack?

What do you recommend?

Edit: This was wrong, look at the my next reply below

Should be able to enter as an expression inline like .../stack{{ $json['exampleData'] }}.yaml and that should work for you

Hey @liam,

It didn’t work, he returned

{“code”:404,“message”:“The requested webhook "GET 350ac731-0a1a-4a85-be6b-b561235d59e6/stack-portainer.yaml" is not registered.”,“hint”:"The workflow must be active for a production URL to run successfully. You can activate the workflow using the toggle in the top-right of the editor. Note that unlike test URL calls, production URL calls aren’t shown on the screen (only in the executions list) "}

How would I send this exampleData to enter the webhook request?

Sorry I actually misunderstood.

You can do this by specifying headers in the response node. There is another post about this here.

Response Headers:
name: content-disposition
value: attachment; filename="{{ $json['exampleData'] }}.yaml"

@htnrodrigues , I would make a slight correction to the example in Response to Webhook configuration @liam provided. The actual filename in the header would likely be {{ $binary.stack.fileName }} (as opposed to $json...) assuming stack is the name of the Destination Key in the Convert to/from binary data node.

For clarity, here’s your original workflow reworked to have the idea with the header change implemented.

3 Likes

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