HTTP Endpoint to Serve External File Download - n8n Workflow

Use this reliable n8n workflow to create a public HTTP endpoint that fetches an external file (like a PDF) and forces a download response. Learn how to handle binary files using n8n templates.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Developers building microservices or custom APIs.
Teams needing to provide temporary or controlled download links for documents.
Users looking to understand how to handle binary data and custom headers within an n8n workflow.
Automation specialists utilizing n8n for file delivery solutions.

Overview

When building complex applications, it is often necessary to serve files from a custom endpoint without exposing the original source URL. This powerful n8n workflow solves that problem by acting as a proxy and delivery service. It uses an n8n trigger to initiate the process upon a GET request. The automation fetches an external PDF document, converts it into binary data, and then immediately responds to the original requester, forcing a download with a custom, dynamically dated filename. This reliable n8n template is essential for creating secure, branded, and temporary download links without writing complex backend code. Every step, using specialized n8n node configurations, ensures high performance and correct binary file handling.

How it Works

This n8n workflow operates sequentially, ensuring the file is fetched before the response is sent:


  1. Initiation (The n8n Trigger): The workflow starts with the 'On GET request' n8n trigger node. It listens for incoming HTTP GET requests at a specific path, configured here as /download-pdf.

  2. File Retrieval: Once the n8n trigger is activated, the 'Fetch binary file' n8n node takes over. It sends an external HTTP request to the specified PDF URL (in this case, a public document hosted on deutschebahn.com). Crucially, this n8n node is configured to receive the response as a binary file, ready for transmission.

  3. Response Handling: Finally, the 'Respond with attachment' n8n node captures the binary data output from the previous step. It uses the respondToWebhook capability to immediately send this binary file back to the client that initiated the original request. It also includes a custom content-disposition header, ensuring the client's browser downloads the file with a specific name, dynamically generated using the current date via n8n's expression capabilities.

Installation Guide

To start using this specific n8n workflow, follow these steps:


  1. Import the n8n template: Copy the provided JSON code and paste it into your n8n instance using the 'New' menu > 'Import from JSON'.

  2. Activate the Webhook: After importing, ensure the 'On GET request' n8n trigger node is correctly linked to a public URL endpoint. Save the workflow.

  3. Test the n8n Trigger: Activate the workflow. You can test the setup by accessing the generated URL (e.g., YOURN8NURL/webhook/download-pdf) in your browser or using a tool like Postman.

  4. Customization: Modify the 'Fetch binary file' n8n node to point to your desired external file URL. Adjust the filename expression in the 'Respond with attachment' n8n node if needed.

Node Details

On GET request (Webhook):
Function: Serves as the primary n8n trigger, waiting for external activation.
Key Configuration: Configured for a GET method on the path /download-pdf. Response mode is set to 'Respond with Response Node' to ensure it waits for the final 'Respond with attachment' n8n node.

Fetch binary file (HTTP Request):
Function: Retrieves the external PDF document.
Key Configuration: The URL is hardcoded to the target PDF. The crucial setting is 'Response Format' under the 'Options' tab, which is set to File to correctly handle the binary content.

Respond with attachment (Respond to Webhook):
Function: Sends the received binary data back to the user who triggered the n8n workflow.
* Key Configuration: Responds using the 'Binary Data' option. A custom header, content-disposition, is added to force the file download and set the filename dynamically using an n8n expression: mydocument{{ $now.toFormat('yyyy-MM-dd') }}.pdf.

Related n8n Workflows

Free

Nodes: 3 Nodes
Updated: December 26 2025
View all
Created by

Featured*