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
Parameter | Type | Description |
---|---|---|
ctx | Context | The Matterway SDK context. |
file | SdkFile | The SdkFile object containing the file data and metadata to be attached. |
selector | string | The 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);