🐛 Fix issue getting binary data when filesystem mode is used - Move Binary Data (#2727)

* 🐛 Fix issue getting binary data when filesystem mode is used

*  Simplifications

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Ricardo Espinoza 2022-01-28 02:46:30 -05:00 committed by GitHub
parent 48b2a0b857
commit 3cde6bd426
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -394,18 +394,23 @@ export class MoveBinaryData implements INodeType {
}
const encoding = (options.encoding as string) || 'utf8';
let convertedValue = value.data;
const buffer = await this.helpers.getBinaryDataBuffer(itemIndex, sourceKey);
let convertedValue: string;
if (setAllData === true) {
// Set the full data
convertedValue = iconv.decode(Buffer.from(convertedValue, BINARY_ENCODING), encoding, { stripBOM: options.stripBOM as boolean });
convertedValue = iconv.decode(buffer, encoding, { stripBOM: options.stripBOM as boolean });
newItem.json = JSON.parse(convertedValue);
} else {
// Does get added to existing data so copy it first
newItem.json = JSON.parse(JSON.stringify(item.json));
if (options.keepAsBase64 !== true) {
convertedValue = iconv.decode(Buffer.from(convertedValue, BINARY_ENCODING), encoding, { stripBOM: options.stripBOM as boolean });
convertedValue = iconv.decode(buffer, encoding, { stripBOM: options.stripBOM as boolean });
} else {
convertedValue = Buffer.from(buffer).toString(BINARY_ENCODING);
}
if (options.jsonParse) {