UNPKG

@fgv/ts-web-extras

Version:

Browser-compatible utilities and FileTree implementations

77 lines (36 loc) 1.55 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@fgv/ts-web-extras](./ts-web-extras.md) &gt; [FileTreeHelpers](./ts-web-extras.filetreehelpers.md) &gt; [fromFileList](./ts-web-extras.filetreehelpers.fromfilelist.md) ## FileTreeHelpers.fromFileList() function Helper function to create a new FileTree instance from a browser FileList (e.g., from input\[type="file"\]). **Signature:** ```typescript export declare function fromFileList(fileList: FileList, params?: FileTree.IFileTreeInitParams<string>): Promise<Result<FileTree.FileTree<string>>>; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> fileList </td><td> FileList </td><td> FileList from a file input element </td></tr> <tr><td> params </td><td> FileTree.IFileTreeInitParams&lt;string&gt; </td><td> _(Optional)_ Optional `IFileTreeInitParams` for the file tree. </td></tr> </tbody></table> **Returns:** Promise&lt;Result&lt;FileTree.FileTree&lt;string&gt;&gt;&gt; Promise resolving to a successful Result with the new FileTree instance if successful, or a failed Result with an error message otherwise ## Remarks The content type of the files is always `string` and the default accept contentType function (`FileTree.FileItem.defaultAcceptContentType`<!-- -->) is used, so content type is derived from the mime type of the file, when available.