downloadFile

Diese Aktion startet im Browser den Download einer Datei, deren Inhalt und Metadaten im Payload übergeben werden. Sie wird häufig als Folgeaktion in der Server-Response eines submit eingesetzt, wenn das Backend aus den Formulardaten ein Dokument (z. B. ein PDF) erzeugt und direkt zum Herunterladen bereitstellt.

Übersicht

action ("downloadFile")

Auszuführende Aktion.

payload (DownloadFileActionPayload)

Definiert Inhalt der herunterzuladenden Datei.

DownloadFileActionPayload

base64Encoded (boolean)

Gibt an, ob die Datei base64 kodiert ist.

data (string)

Inhalt der Datei.

fileName (string)

Name der Datei.

mimeType (string)

Typ der Datei.

Beispiel

downloadFile.json
{
  "$schema": "https://forms.virtimo.net/5.0.x/schema.json",
  "metaData": {
    "id": "0",
    "version": 0
  },
  "configuration": {
  },
  "components": [
    {
      "type": "container",
      "components": [
        {
          "type": "button",
          "label": "Download base64 encoded file",
          "onClick": {
            "action": "downloadFile",
            "payload": {
              "base64Encoded": true,
              "data": "PG1zZz4KPGNvbnRlbnQ+SGVsbG8gV29ybGQ8L2NvbnRlbnQ+CjwvbXNnPg==",
              "fileName" : "testfile.xml",
              "mimeType": "application/xml"
            }
          }
        },
        {
          "type": "button",
          "label": "Download textfile",
          "onClick": {
            "action": "downloadFile",
            "payload": {
              "fileName" : "testfile.txt",
              "data": "Hello World"
            }
          }
        }
      ]
    }
  ]
}
Eingebettete Vorschau

Keywords: