Upload

The Upload Files action allows you to upload one or more files to a remote API endpoint. It provides full control over the upload stream and supports custom success and error handling, along with advanced options like cancel tokens and stream controllers.

Use Cases

  • Uploading user-selected images, videos, or documents to a server.

  • Triggering uploads after form submissions.

  • Handling upload success and failure scenarios programmatically.

Properties

Property
Description

dataSource

The API endpoint used to upload the file(s).

successCondition

A boolean expression used to determine if the upload was successful.

onSuccess

Action flow to run when the upload succeeds and successCondition is met.

onError

Action flow to run when the upload fails or successCondition returns false.

streamController

An optional expression to pass a custom stream controller to track progress or state.

cancelToken

An optional expression used to allow cancellation of the upload request.

Default Behavior

  • Sends file data to the provided dataSource using a multipart/form-data request.

  • Monitors the response based on successCondition.

  • Executes onSuccess or onError based on the upload result.

  • Supports optional stream control and cancellation for advanced usage.

How to Use

  1. Attach the action to a widget event (e.g., after file selection or form submission).

  2. Select Upload Files from the action list.

  3. Configure the dataSource with your upload API.

  4. Optionally define a successCondition, onSuccess, and onError.

  5. Use streamController or cancelToken if you need fine-grained control over the upload lifecycle.

Last updated