mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(GitHub Node): File Create operation prevent duplicated base64 encoding (#10040)
This commit is contained in:
@@ -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)}`;
|
||||
|
||||
Reference in New Issue
Block a user