Skip to content

io.input.file ​

Represents a file component.

Usage ​

ts
const value = await io.input.file("File")
python
value = await io.input.file("File")

example of Forge app with file component

Props ​

allowedExtensions Optional ​

string[]
Array of file extensions accepted by the file input.

disabled Optional ​

boolean
Whether the input is disabled, preventing file uploads.

generatePresignedUrls Optional ​

function
Optional function that generates presigned URLs for uploading and downloading files. Works with any S3-compatible API. Available beginning with SDK v0.24.0.

({ name: string, type: string }) => Promise<{
  uploadUrl: string,
  downloadUrl: string,
}>

helpText Optional ​

string
Secondary label providing additional context for the file. Supports inline markdown elements like bold, italics, and links.

Returns object ​

extension ​

string
The file's extension. An empty string if the file name does not have one.

lastModified ​

Date
A JavaScript Date object representing the modification date of the file.

name ​

string
The name of the file.

size ​

number
The size of the file in bytes.

type ​

string
The MIME type of the file.

buffer() ​

() => Promise<Buffer>
An asynchronous function returning the file's contents as a Buffer object.

json() ​

() => Promise<any>
An asynchronous fallible function returning the file's contents as a deserialized object. Can fail if file is not valid JSON.

text() ​

() => Promise<string>
An asynchronous fallible function returning the file's contents as a string. Can fail if file cannot be serialized to a string.

url() ​

() => Promise<string>
An asynchronous function returning a temporary presigned URL to the file.