fix(GitHub Node): File Create operation prevent duplicated base64 encoding (#10040)

This commit is contained in:
Marcus
2024-07-12 17:37:00 +02:00
committed by GitHub
parent 46d6edc2a4
commit 9bcc926a91
2 changed files with 17 additions and 6 deletions

View File

@@ -9,7 +9,12 @@ import type {
import { NodeOperationError } from 'n8n-workflow';
import { snakeCase } from 'change-case';
import { getFileSha, githubApiRequest, githubApiRequestAllItems } from './GenericFunctions';
import {
getFileSha,
githubApiRequest,
githubApiRequestAllItems,
isBase64,
} from './GenericFunctions';
import { getRepositories, getUsers } from './SearchFunctions';
@@ -1981,11 +1986,12 @@ export class Github implements INodeType {
// TODO: Does this work with filesystem mode
body.content = binaryData.data;
} else {
// Is text file
// body.content = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'base64');
body.content = Buffer.from(
this.getNodeParameter('fileContent', i) as string,
).toString('base64');
const fileContent = this.getNodeParameter('fileContent', i) as string;
if (isBase64(fileContent)) {
body.content = fileContent;
} else {
body.content = Buffer.from(fileContent).toString('base64');
}
}
endpoint = `/repos/${owner}/${repository}/contents/${encodeURI(filePath)}`;