Restrict file upload type in n8n

Restrict file upload type in n8n

Currently n8n allows any file type to upload. But due to some security restrictions we want to only allow specific type of files to upload. Specially in “On Chat Message node”.

I didn`t find any way to do this, So i tried to remove the On Chat Message Node and Chat Trigger using this ENV variable as

NODES_EXCLUDE=[“n8n/n8n-nodes-langchain.chatTrigger”,“n8n/n8n-nodes-langchain.chatMessage”,“n8n-nodes-base.executeCommand”,“n8n-nodes-base.ssh”]

SSh and executeCommand is disabled but not the chat node.

Information on your n8n setup

  • n8n version:[1.110.1]
  • Database (default: SQLite):
  • Running n8n via (Docker):
  • Operating system: [RHEL7]

What you can do is:

Workflow logic immediately after upload
Add a Switch node after the Chat Trigger, checking $json.files[...]. For example:

Allowed file types = [ “application/pdf”, “image/png”, “image/jpeg” ]
Condition: mimeType is in Allowed file types

  1. If true → continue. If false → respond with a chat message “Sorry, only PDF, PNG or JPEG files allowed.”
  2. Return a meaningful user message so user knows what failed, instead of just dropping the file silently.

Currently in a straight forward way, n8n does not have this functionality

What i want is to disable it from somewhere so that it should not be available while creating workflows. There will be multiple users, so any one can allow it in there workflow and files will be directly uploaded into server.

You missed an @ in the definition of the trigger.

Check better here :

Finally this worked.

NODES_EXCLUDE=[“@n8n/n8n-nodes-langchain.chatTrigger”,“@n8n/n8n-nodes-langchain.chat”,“n8n-nodes-base.executeCommand”]

2 Likes

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