SpiffWorks SpiffWorks Learn More →

Navigation

  • index
  • next |
  • previous |
  • Spiff Arena 0.1 documentation »
  • How-to Guides »
  • Build Diagrams »
  • File Upload and Markdown Link Display

Spiff Arena

  • Tutorials
  • How-to Guides
    • Build Diagrams
      • Create a BPMN Diagram
      • Use User Tasks and Forms
      • Assigning Tasks to People
      • Send and Receive Messages Between Processes
      • Start a Process When a Human Task Becomes Available
      • Display Content
      • Overview of Built-in Examples
      • Use Executable and Non-Executable Tasks
      • BPMN Unit Tests
      • File Upload and Markdown Link Display
        • Process Overview
        • Task Configuration Details
      • Long-Running Service Tasks
    • Manage Processes
    • Manage Welcome Messages
    • Use Custom Process Metadata
    • Use Human Task Metadata
    • Use Process Metadata Backfill
    • Troubleshoot Locally
    • Deploy
    • Extend the System
  • Explanation
  • Reference

Additional Documentation

  • SpiffWorks Learn

Quick search

File Upload and Markdown Link Display¶

This guide documents a process in Spiffworkflow where a user uploads a file, the system generates a downloadable markdown link to the file, and then displays that link back to the user in a follow-up task.

This can be used for tasks such as submitting documents, generating downloadable reports, or capturing file inputs for later reference or distribution.

Process Overview¶

File Upload Process

This process allows a user to upload a file using a form. The uploaded file is converted into a markdown-compatible link by a script, and the link is then shown to the user in a final confirmation task.

Workflow Steps:

  • User uploads a file in the initial task.

  • A script task converts the file into a markdown download link.

  • A confirmation message is displayed with the link.

Task Configuration Details¶

1. User Task: Example Manual Task¶

Type: User Task
Purpose: Collect a file upload from the user.
UI Output: Presents a file selection form with a “Submit” and “Save and Close” button.

JSON Schema (Form Definition)¶

{
  "title": "Files",
  "type": "object",
  "properties": {
    "file": {
      "type": "string",
      "format": "data-url",
      "title": "Single file"
    }
  }
}
  • file: This property captures a file as a data URL string. When the task is submitted, Arena stores the original bytes separately and replaces the value of file with an internal file reference. Keep that reference unchanged in later tasks; it is not a base64-encoded copy of the file.

UI Schema¶

{
  "file": {
    "ui:options": {
      "accept": ".pdf"
    }
  }
}
  • The "accept" attribute can be configured to restrict allowed file types (e.g., “.pdf”, “.png”, “.jpg”).

UI Behavior¶

  • Users click “Choose File” and select a document to upload.

  • After selection, the file name, type, and size are shown.

  • On clicking “Submit”, Arena stores the file and passes its internal reference to the next task.

  • In read-only or disabled views, saved files appear as a list with download links (when process instance context is available), without upload or removal controls.

File Upload Step
The interface displays the uploaded filename, type, and size before submission.

File Upload Process

2. Script Task: Generate Link to File¶

Type: Script Task
Purpose: Convert the uploaded file into a markdown-compatible download link.

Script¶

link = markdown_file_download_link(file)
  • file: This is the stored file reference from the previous task. Generate the link in a script task after the upload task has been submitted.

  • markdown_file_download_link() is a built-in function that generates a string like:

    [filename.ext](https://your-server.com/path/to/file)
    
  • The output is stored in the process variable link.

3. Manual Task: Display Link to File¶

Type: Manual Task
Purpose: Show a confirmation message to the user with a clickable link.

Instructions (Displayed Text)¶

Thanks for uploading a file!  
Here is a link: {{link}}
  • The {{link}} variable is dynamically replaced with the markdown download link generated in the previous step.

Display Link to File Step
This shows a text message with a link: [filename.ext]”
File Upload Process

The same {{link}} can be reused in later tasks and after reloading the page. Downloads still require file-download permissions.

Stored references are not base64 file contents. Use markdown_file_download_link(file) to generate a download link.

Getting every file uploaded to a process instance¶

Task data holds only the files that the current form values reference. If a user replaces a file, or a script deletes a variable, the file is still stored but task data no longer points to it. To list every file uploaded to the current process instance, oldest first, call get_process_instance_files(). Each item has id, filename, mimetype, digest, created_at_in_seconds, and file_reference. file_reference is the value that task data holds, so markdown_file_download_link() accepts it.

To send the file contents to a service task, call get_process_instance_files(include_contents=True) in the parameter value. Each item then also has data_url. Do not assign that result to a variable in a script, because the contents would then be stored in task data.

Showing the attachment in a follow-up form¶

A later user task can reuse the file property from the JSON schema above and make it read-only:

{
  "file": {
    "ui:readonly": true
  }
}

With ui:options.filePreview enabled, unsaved files use local previews; stored attachments use authenticated download links.

You can modify the final message formatting to include file size or type if those details are captured.

← BPMN Unit TestsLong-Running Service Tasks →
© Copyright 2026, SpiffWorks. Created using Sphinx 8.2.3.