refactor(core): Create controller for binary data (no-changelog) (#7363)

This PR adds a controller for binary data + integration tests.
This commit is contained in:
Iván Ovejero
2023-10-06 16:21:13 +02:00
committed by GitHub
parent 63e11e4be9
commit 34bda535e6
9 changed files with 217 additions and 53 deletions

View File

@@ -6,7 +6,7 @@ import type { Request, Response } from 'express';
import { parse, stringify } from 'flatted';
import picocolors from 'picocolors';
import { ErrorReporterProxy as ErrorReporter, NodeApiError } from 'n8n-workflow';
import { Readable } from 'node:stream';
import type {
IExecutionDb,
IExecutionFlatted,
@@ -101,6 +101,11 @@ export function sendSuccessResponse(
res.header(responseHeader);
}
if (data instanceof Readable) {
data.pipe(res);
return;
}
if (raw === true) {
if (typeof data === 'string') {
res.send(data);