mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +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:
@@ -26,6 +26,7 @@ export type JsonToBinaryOptions = {
|
||||
mimeType?: string;
|
||||
dataIsBase64?: boolean;
|
||||
itemIndex?: number;
|
||||
format?: boolean;
|
||||
};
|
||||
|
||||
type PdfDocument = Awaited<ReturnType<Awaited<typeof readPDF>>['promise']>;
|
||||
@@ -102,7 +103,11 @@ export async function createBinaryFromJson(
|
||||
|
||||
if (typeof value === 'object') {
|
||||
options.mimeType = 'application/json';
|
||||
valueAsString = JSON.stringify(value);
|
||||
if (options.format) {
|
||||
valueAsString = JSON.stringify(value, null, 2);
|
||||
} else {
|
||||
valueAsString = JSON.stringify(value);
|
||||
}
|
||||
}
|
||||
|
||||
buffer = iconv.encode(valueAsString, options.encoding || 'utf8', {
|
||||
|
||||
Reference in New Issue
Block a user