Skip to main content

sdk.file_2.showuploadfile

Home > @matterway/sdk > File_2 > showUploadFile

File_2.showUploadFile() function

Displays a file upload dialog and returns an array of SdkFile objects containing the selected files' data and metadata.

Signature:

export declare function showUploadFile(ctx: Context, options: ShowUploadFileOptions): Promise<SdkFile[] | null>;

Parameters

ParameterTypeDescription
ctxContextThe context object that provides access to the render method.
optionsShowUploadFileOptionsThe options to configure the file upload dialog.

Returns:

Promise<SdkFile[] | null>

A promise that resolves with an array of SdkFile objects, or null if the user cancels the dialog.

Example

const options = { fileUploadTitle: 'Upload Files', uploadButton: 'Upload', fileLimit: 3, error: 'You can upload up to 3 files only.', validate: async (file) => { if (file.size > 1024 * 1024) { return { isValid: false, message: 'File size exceeds 1MB.' }; } return { isValid: true, message: '' }; }, }; const selectedFiles = await showAcceptFile(context, options); if (selectedFiles) { // Process the selected files. }