Skip to content

SupFile

The SupFile object represents assets uploaded in the patch editor that aren’t images, audio, or video.

Example File
{
"name": "document.pdf",
"url": "https://user-uploads.cdn.overworld.xyz/r2kxmp9wvqft8nu5hjc3bsg4.pdf",
"mimeType": "application/pdf"
}

Properties

name

type: string | undefined

The original filename, if available.

mimeType

type: string

The MIME type of the file (e.g., “application/pdf”, “text/plain”).

url

type: string

Gets the CDN URL for the file.

blob

type: Blob

Gets the file data as a Blob. The file will be downloaded when this property is first accessed.

text

type: string

Gets the file content as text. Use this to read the contents of a text file.

function main() {
const file = sup.file('horosocopes.json'); // horoscopes.json is uploaded as an asset
const horoscopes = JSON.parse(file.text);
return sup.random.choice(horoscopes.virgo);
}

Output

Returning a SupFile from a patch’s main() function will display a file attachment in the chat.

function main() {
return sup.file(
"https://example.com/document.pdf",
"application/pdf",
);
}