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.
Properties
API Call
Dropdown and value
✅
Select API call from dropdown and fill their respective API params
Success Condition
Expression (Boolean)
❌
Optional expression to determine if the upload was successful
On Success
Action Flow
❌
Actions to execute when upload succeeds
On Error
Action Flow
❌
Actions to execute when upload fails
Stream Controller
Dropdown
❌
Select stream controller variable to track upload progress
Cancel Token
Dropdown
❌
Select cancel token variable to allow upload cancellation
Use Cases
File Sharing: Upload user-selected files to cloud storage
Media Upload: Send images, videos, or audio files to servers
Document Processing: Submit documents for processing or storage
Form Submissions: Upload files as part of form data
Backup Services: Send files to backup or archive services
Default Behavior
By default:
Request Format
Uses multipart/form-data for file uploads
Success Evaluation
All responses treated as successful if no condition specified
Progress Tracking
Progress events emitted when stream controller provided
Cancellation
Upload can be cancelled using provided cancel token
Response Access
Upload response available as {{response}} in action flows
How to Use

Attach the action to a widget event (file selection, form submission, etc.)
Select Upload from the action list
Select
API Callfrom dropdown and fill their respective paramsSet optional
Success Conditionto define success criteriaDefine
On SuccessandOn Erroraction flows as neededUse
Stream Controllerfor progress tracking if requiredUse
Cancel Tokenfor upload cancellation if needed
Implementation Details
The action uses Dio for HTTP requests and sends files as multipart/form-data. The response object contains:
body
Response body data
statusCode
HTTP status code
headers
Response headers map
requestObj
Request details (URL, method, headers, data)
error
Error message (null for successful uploads)
Success Condition Examples:
isEqual(response.statusCode, 200)- Success only on HTTP 200and(gte(response.statusCode, 200), lt(response.statusCode, 300))- Success on 2xx status codesisEqual(jsonGet(response.body, 'success'), true)- Success based on response body content
Related Actions
File Picker - Select files to upload
Image Picker - Select images/videos for upload
Call Rest API - General API communication
Set State - Update UI state with upload results
Asset Placeholder: Tutorial video demonstrating file upload workflows and progress tracking in Digia Studio
Last updated