mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(Convert to File Node): Operation to convert a string in a plain text file, option to format JSON when creating file (#8620)
This commit is contained in:
@@ -54,6 +54,11 @@ export const properties: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'Whether the data is already base64 encoded',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'@version': [1],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Encoding',
|
||||
@@ -65,6 +70,7 @@ export const properties: INodeProperties[] = [
|
||||
displayOptions: {
|
||||
hide: {
|
||||
dataIsBase64: [true],
|
||||
'@version': [{ _cnd: { gt: 1 } }],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -100,17 +106,24 @@ export const description = updateDisplayOptions(displayOptions, properties);
|
||||
export async function execute(this: IExecuteFunctions, items: INodeExecutionData[]) {
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
|
||||
const nodeVersion = this.getNode().typeVersion;
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
try {
|
||||
const options = this.getNodeParameter('options', i, {});
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i, 'data');
|
||||
const sourceProperty = this.getNodeParameter('sourceProperty', i) as string;
|
||||
|
||||
let dataIsBase64 = true;
|
||||
if (nodeVersion === 1) {
|
||||
dataIsBase64 = options.dataIsBase64 !== false;
|
||||
}
|
||||
|
||||
const jsonToBinaryOptions: JsonToBinaryOptions = {
|
||||
sourceKey: sourceProperty,
|
||||
fileName: options.fileName as string,
|
||||
mimeType: options.mimeType as string,
|
||||
dataIsBase64: options.dataIsBase64 !== false,
|
||||
dataIsBase64,
|
||||
encoding: options.encoding as string,
|
||||
addBOM: options.addBOM as boolean,
|
||||
itemIndex: i,
|
||||
|
||||
Reference in New Issue
Block a user