$files
Updated on Aug 25, 2025 6 minutes to readThe Files Plugin provides a set of methods to manage, upload, download, preview, and manipulate files in the application.
Methods
Method | Description |
---|---|
download | Downloads a file by ID. |
downloadBase64 | Downloads a file and returns its Base64 string. |
getDownloadUrl | Returns the URL to download a file. |
getInfo | Returns detailed information about a file. |
getPublicUrl | Returns the public URL of a file. |
getThumbnailUrl | Returns the URL of a file thumbnail. |
makePrivate | Sets a file to private. |
makePublic | Sets a file to public. |
preview | Previews a file or a list of files. |
previewOrDownload | Previews a file if supported or downloads it otherwise. |
upload | Uploads a file from local selection or mobile device. |
uploadBase64 | Uploads a file from a Base64 string. |
Methods Details
download()
• Type
(id: string, params?: DownloadFileParams) => void
• Details
Expects a file ID
and optional DownloadFileParams (default: { inline: true }
if the MIME type is application/pdf
and the environment is not a mobile application; { inline: false }
in all other cases).
Downloads the file to the client or device.
downloadBase64()
• Type
(id: string) => Promise<string>
• Details
Expects a file ID.
Returns a Promise that resolves with the Base64 string representation of the file.
getDownloadUrl()
• Type
(id: string, schema?: boolean, params?: BaseFileParams) => string
• Details
Expects a file ID,
an optional schema flag (default: false
) that specifies whether the returned URL should be absolute or relative,
and optional BaseFileParams (default: null
).
Returns the URL to download the file.
getInfo()
• Type
(id: string) => Promise<FileInfo>
• Details
Expects a file ID.
Returns a Promise that resolves with a FileInfo object.
getPublicUrl()
• Type
(id: string, schema?: boolean) => Promise<string | null>
• Details
Expects a file ID
and optional schema flag (default: false
) that specifies whether the returned URL should be absolute or relative,
Returns a Promise that resolves with the public URL of the file if available, or null
.
getThumbnailUrl()
• Type
(
id: string,
size?: number,
schema?: boolean,
params?: ThumbnailFileParams
) => string
• Details
Expects a file ID,
an optional size (default: 50
),
an optional schema flag (default: false
) that specifies whether the returned URL should be absolute or relative,
and optional ThumbnailFileParams.
Returns the URL of the file thumbnail.
makePrivate()
• Type
(id: string) => Promise<void>
• Details
Expects a file ID.
Sets the file as private and returns a Promise that resolves when complete.
makePublic()
• Type
(id: string, params?: PublicFileParams) => Promise<void>
• Details
Expects a file ID and optional PublicFileParams.
Sets the file as public and returns a Promise that resolves when complete.
preview()
• Type
(
id: string | string[],
params?: PreviewFileParams
) => Promise<boolean>
• Details
Expects a file ID or array of file IDs and optional PreviewFileParams (default: null
).
Previews the file if supported. Returns a Promise that resolves with true
if preview is shown successfully, false
otherwise.
previewOrDownload()
• Type
(
id: string,
params?: PreviewFileParams | DownloadFileParams
) => Promise<boolean>
• Details
Expects a file ID and optional PreviewFileParams or DownloadFileParams (default: null
).
Previews the file if supported or downloads it otherwise. Returns a Promise resolving to true
if action is successful, false
otherwise.
upload()
• Type
(
ownerScriptAlias: E8ScriptAlias,
attrScriptAlias: E8ScriptAlias,
progressCallback?: Function
) => Promise<FileInfo>
• Details
Expects E8ScriptAlias for owner and attribute, and optional progress callback.
Uploads a selected file and returns a Promise resolving with a FileInfo object.
uploadBase64()
• Type
// Overload 1: single object parameter
(uploadBase64DataParams: UploadBase64DataParams) => Promise<FileInfo>;
// Overload 2: separate parameters
(
ownerScriptAlias: E8ScriptAlias,
attrScriptAlias: E8ScriptAlias,
data: UploadBase64Data,
progressCallback?: Function
) => Promise<FileInfo>;
• Details
Overload 1: Expects a structured object (UploadBase64DataParams).
Overload 2: Expects individual parameters: ownerScriptAlias (E8ScriptAlias), attrScriptAlias (E8ScriptAlias), data (UploadBase64Data) with basename and base64str, and optional progressCallback function.
Returns a Promise that resolves with the uploaded FileInfo object.