Skip to main content

sdk.file_2.filetoinput

Home > @matterway/sdk > File_2 > fileToInput

File_2.fileToInput() function

Attaches a file to an input element on a web page, using the Matterway SDK context to execute the attachment process within the page.

Signature:

export declare function fileToInput(ctx: Context, file: SdkFile, selector: string): Promise<void>;

Parameters

ParameterTypeDescription
ctxContextThe Matterway SDK context.
fileSdkFileThe SdkFile object containing the file data and metadata to be attached.
selectorstringThe selector for the input element on the page.

Returns:

Promise<void>

Promise of void

Example

const file = { name: 'example.txt', data: 'SGVsbG8gV29ybGQh', type: 'text/plain' }; const selector = 'input[type="file"]'; await fileToInput(context, file, selector);