core2-jvm (latest)
core2-jvm (latest)core-jvm
  • Home
  • Features
  • Spec
  • Guides
  • Sandbox
  • Step Studio
  • Step
    • Action
    • External
    • Help
    • Link Handler
    • Navigation
    • Persist Async
    • Polling
    • Refresh On Change
    • Schema On Change
    • Step Error
    • Suggestions
    • Summary
    • Toolbar
    • Upload
    • Validate Async
    • Schema
    • All Of Schema
    • Array Schema
    • Blob Schema
    • Boolean Schema
    • Const Schema
    • Integer Schema
    • Number Schema
    • Object Schema
    • One Of Schema
    • String Schema
    • Layout
    • Alert Layout
    • Box Layout
    • Button Layout
    • Columns Layout
    • Decision Layout
    • Divider Layout
    • Form Layout
    • Heading Layout
    • Image Layout
    • Instructions Layout
    • List Layout
    • Loading Indicator Layout
    • Markdown Layout
    • Media Layout
    • Modal Layout
    • Paragraph Layout
    • Progress Layout
    • Review Layout
    • Search Layout
    • Section Layout
    • Status List Layout
    • Tabs Layout
    • Upsell Layout
    • Behavior
    • Action Behavior
    • Copy Behavior
    • Dismiss Behavior
    • Link Behavior
    • Modal Behavior
    • Refresh Behavior
    • Subflow Behavior
    • Subflow
    • Dynamic Launch Config
    • Launch Config
    • Modal Presentation
    • Native Launch Config
    • Presentation
    • Push Presentation
    • Action Response Body
    • Error Response Body
    • Flow Response
    • Modal Response Body
    • No Op Response Body
    • Search Initial Layout Config
    • Search Initial Results Config
    • Search Initial State
    • Search Layout Response Body
    • Search Response
    • Search Response Body
    • Search Result
    • Search Results Response Body
    • Subflow Response Body
    • Additional Info
    • Align
    • Autocapitalization Type
    • Autocomplete Token
    • Context
    • Icon
    • Image
    • Inline Alert
    • Media
    • Native Capabilities
    • Request
    • Size
    • Supporting Values
    • Control
    • Tag

Upload

Android - 8.25.0 iOS - 11539 Web - 2.5.0

The upload feature allows a file to be uploaded to an endpoint using multipart form-data or base64 formats.

A file upload component will be rendered when:

  • Any schema has Persist Async configured with an inner Blob Schema
  • A String Schema is configured with the base64url format

Warning: Using String Schema with the base64url format is not encouraged as it can lead to performance issues, particularly with larger files. Base64 encoding is inefficient which leads to an increased upload size when compared to the original binary.

Always prefer using Persist Async with Blob Schema for a better upload experience.

Step.build {
    id = "upload-example"
    title = "Upload Example"
    schemas {
        obj {
            properties {

                // Recommended
                string("multiPartFile") {
                    title = "Multipart upload"
                    persistAsync {
                        url = "/persistAsyncUrl"
                        method = HttpMethod.POST
                        param = "secretParam"
                        idProperty = "secretIdProperty"
                        schema = BlobSchema.build {
                            title = "Invoice"
                            description = "PNG, JPG, or PDF, less than 5mb"
                            source = Upload.Source.FILE
                            accepts = listOf(
                                "image/png",
                                "image/jpg",
                                "application/pdf"
                            )
                        }
                    }
                }

                // Not recommended
                string("base64File") {
                    title = "Base64 upload"
                    description = "PNG, JPG, or PDF, less than 5mb"
                    format = StringSchema.Format.BASE64URL
                    source = Upload.Source.FILE
                    accepts = listOf(
                        "image/png",
                        "image/jpg",
                        "application/pdf"
                    )
                }
            }
        }
    }
}

For multi-file uploads, array schemas can be used in combination with any of the options described earlier

Step.build {
    id = "upload-example"
    title = "Upload Example"
    schemas {
        obj {
            properties {
                list("multiUploadPersistBlob") {
                    minItems = 1
                    maxItems = 3
                    title = "Multi-file upload with persist async blob schema"
                    addItemTitle = "ignored"
                    editItemTitle = "ignored"
                    items = StringSchema.build {
                        persistAsync {
                            url = "/persistAsyncUrl"
                            method = HttpMethod.POST
                            param = "secretParam"
                            idProperty = "secretIdProperty"
                            schema = BlobSchema.build {
                                source = Upload.Source.FILE
                                description = "PNG, JPG, or PDF, less than 5mb"
                                accepts = listOf(
                                    "image/png",
                                    "image/jpg",
                                    "application/pdf"
                                )
                            }
                        }
                    }
                }
            }
        }
    }
}

Properties

PropertyTypeRequiredDescription
acceptsArray<String>NoArray of MIME types the field should accept. If null, any type of file is accepted. Wildcard MIME types are allowed, but support for them varies from platform to platform. Clients must support at least image, audio, and video. Any unrecognised MIME types will be ignored.
cameraConfigAnyNoProvide client-specific configuration for the camera capture experience.
maxSizeLongNoThe maximum file size in bytes. If null, file size is unlimited.
sourceUpload.SourceNoValid sources for the file. If null, any source is permitted.

Related Types

Source

The possible sources for a file

Values

ValueDescription
cameraUse the camera to capture media
fileUse a file picker to select an existing file