fix(HTTP Request Node): Respect the original encoding of the incoming response (#9869)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-07-11 17:03:52 +02:00
committed by GitHub
parent e84ab35c4a
commit 2d19aef540
9 changed files with 152 additions and 41 deletions

View File

@@ -3,7 +3,7 @@ import prettyBytes from 'pretty-bytes';
import Container, { Service } from 'typedi';
import { BINARY_ENCODING } from 'n8n-workflow';
import { InvalidModeError } from '../errors/invalid-mode.error';
import { areConfigModes, toBuffer } from './utils';
import { areConfigModes, binaryToBuffer } from './utils';
import type { Readable } from 'stream';
import type { BinaryData } from './types';
@@ -84,7 +84,7 @@ export class BinaryDataService {
const manager = this.managers[this.mode];
if (!manager) {
const buffer = await this.toBuffer(bufferOrStream);
const buffer = await binaryToBuffer(bufferOrStream);
binaryData.data = buffer.toString(BINARY_ENCODING);
binaryData.fileSize = prettyBytes(buffer.length);
@@ -110,10 +110,6 @@ export class BinaryDataService {
return binaryData;
}
async toBuffer(bufferOrStream: Buffer | Readable) {
return await toBuffer(bufferOrStream);
}
async getAsStream(binaryDataId: string, chunkSize?: number) {
const [mode, fileId] = binaryDataId.split(':');