openFile IO
¶
openFile API is used to open and read files content from user disk. It opens a dialog box and prompts user to select a file or multiple files to open.
Syntax¶
openFile(callback: function, options: object)
Example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import INKAPI from './inkapi.js'
INKAPI.ready(() => {
const IO = INKAPI.io;
//open dialog with txt file
const callback = (data) => console.log(data);
IO.openFile(callback, { ext: "txt", allowMultipleFiles: false })
/*
Console Output on file open callback:
[
{
path: "C:\Users\Me\sample.txt",
filename: : "sample.txt",
data: Uint8Array(114) [ ... ]
}
]
*/
});
|
Parameters¶
Name |
Type |
Description |
---|---|---|
callback |
|
Required. callback to be triggered with opened file content. |
options |
|
Required. Extension for save dialog filters. |
options¶
Name |
Type |
Description |
---|---|---|
ext |
|
Extension filter for open dialog box. |
allowMultipleFiles |
|
If true user can select multiple files from open dialog box. |