Skip to main content

Overview

Workflows can generate files and upload them to Codika’s storage using the Codika Upload File node. The uploaded file gets a documentId that can be included in the workflow’s output as a file type field.

Pattern

Generate/Download File → Codika Upload File → Code Node (extract documentId) → Codika Submit Result

Step 1: Generate or download the file

Use any n8n node that produces binary data:
{
  "type": "n8n-nodes-base.httpRequest",
  "parameters": {
    "url": "https://api.example.com/generate-pdf",
    "responseFormat": "file"
  },
  "name": "Generate PDF"
}

Step 2: Upload with Codika Upload File

{
  "type": "n8n-nodes-codika.codika",
  "typeVersion": 1,
  "parameters": {
    "resource": "fileManagement",
    "operation": "uploadFile"
  },
  "name": "Upload File"
}
The node uploads the binary data from the previous node and returns a documentId.

Step 3: Return the documentId in output

In a Code node before Codika Submit Result:
const documentId = $('Upload File').first().json.documentId;

return [{
  json: {
    results: {
      generated_report: documentId,
      summary: 'Report generated successfully',
    }
  }
}];

Step 4: Define file type in output schema

In config.ts:
function getOutputSchema(): FormOutputSchema {
  return [
    {
      key: 'generated_report',
      type: 'file',
      label: 'Generated Report',
      description: 'PDF report generated by the workflow',
    },
    {
      key: 'summary',
      type: 'string',
      label: 'Summary',
      description: 'Brief summary of the report',
    },
  ];
}

File uploads in sub-workflows

Sub-workflows do not have their own Codika Init node, so the Upload File node needs explicit execution metadata. The parent must forward executionId and executionSecret.

Parent workflow passes metadata

{
  "type": "n8n-nodes-base.executeWorkflow",
  "parameters": {
    "workflowId": {
      "__rl": true,
      "mode": "id",
      "value": "{{SUBWKFL_pdf-generator_LFKWBUS}}"
    },
    "workflowInputs": {
      "mappingMode": "defineBelow",
      "value": {
        "markdownContent": "={{ $json.markdown }}",
        "fileName": "report.pdf",
        "executionId": "={{ $('Codika Init').first().json.executionId }}",
        "executionSecret": "={{ $('Codika Init').first().json.executionSecret }}"
      }
    }
  }
}

Sub-workflow uses overrides

{
  "type": "n8n-nodes-codika.codika",
  "parameters": {
    "resource": "fileManagement",
    "operation": "uploadFile",
    "executionIdOverride": "={{ $('When Called by Parent').first().json.executionId }}",
    "executionSecretOverride": "={{ $('When Called by Parent').first().json.executionSecret }}"
  },
  "name": "Upload File"
}

Sub-workflow input schema in config.ts

{
  type: 'subworkflow' as const,
  inputSchema: [
    { name: 'markdownContent', type: 'string' },
    { name: 'fileName', type: 'string' },
    { name: 'executionId', type: 'string' },
    { name: 'executionSecret', type: 'string' },
  ],
  calledBy: ['main-workflow'],
}

File input (user uploads)

Users can upload files via the input schema:
{
  key: 'document',
  type: 'file',
  label: 'Upload Document',
  required: true,
  maxSize: 50 * 1024 * 1024,
  allowedMimeTypes: ['application/pdf', '.docx', '.doc', '.txt'],
}
The file data arrives in the webhook payload and can be accessed in workflow nodes.

Supported file types for upload

The Codika Upload File node supports:
CategoryTypes
DocumentsPDF, Word (.docx), Excel (.xlsx), Text (.txt)
ImagesPNG, JPG, GIF, SVG, WEBP
ArchivesZIP, TAR, TAR.GZ
MediaVideo (various formats)
DataJSON, YAML, CSV