Skip to content

Conversation

@NoxTav
Copy link

@NoxTav NoxTav commented Apr 22, 2025

Description

Sometimes, APIs return raw images or REST errors in the same endpoint. Right now, if this is the case, the image is shown raw in a json key in n8n and needs more nodes to be shown. This PR would allow us to show the image directly in the result part.

Effects in n8n UI

Display the image directly in the node's window as in the HTTP Request Node .

Side effects

If some use the raw image directly, it might cause them issues. I haven't investigated how it's passed to the next node.

.map(([_, data]) => (data as ResponseObject).content)
.map((content) => Object.keys(content!))
.flat()
.filter((contentType) => contentType.match(/image\/*/))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to handle only images or just regular binary data would be fine?

https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.httprequest/#n8n-binary-file

I'm not expert in how n8n handle files, but may be we could add some general logic for all binary content types? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link for send API, sorry, but the idea is the same - can all binary files be handled this way?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the binary files are handled the same. The key is to put the good fileType inside the postReceive function.

Here is the list of possible keys: https://github.com/n8n-io/n8n/blob/91069f057e8e1bc32b4e2040a53e5c4546b2991f/packages/workflow/src/Interfaces.ts#L44.

I didn't make tests for HTML and text but they should work exactly the same as for the images, videos, audios and pdf.

@NoxTav NoxTav force-pushed the add_image_handling branch from 60683f2 to a9f9414 Compare April 24, 2025 14:09
@NoxTav NoxTav force-pushed the add_image_handling branch from a9f9414 to 1907e64 Compare April 24, 2025 15:53
@NoxTav NoxTav requested a review from devlikepro April 25, 2025 09:00
@NoxTav
Copy link
Author

NoxTav commented May 14, 2025

Hi @devlikepro,
Just a friendly ping — I’ve addressed the feedback and updated the PR. When you have a moment, could you please take another look? Your review would be much appreciated. Thanks!

@NoxTav
Copy link
Author

NoxTav commented Jun 2, 2025

Hi @devlikepro,
Did you have any chance to look at the issue?

@devlikepro
Copy link
Contributor

need to review and test that

@devlikepro devlikepro added the enhancement New feature or request label Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants