UNPKG

@fgv/ts-web-extras

Version:

Browser-compatible utilities and FileTree implementations

77 lines (36 loc) 1.62 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; [fromDirectoryUpload](./ts-web-extras.filetreehelpers.fromdirectoryupload.md) ## FileTreeHelpers.fromDirectoryUpload() function Helper function to create a new FileTree instance from a directory upload with webkitRelativePath support. **Signature:** ```typescript export declare function fromDirectoryUpload(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 directory upload (input with webkitdirectory) </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 is used, so content type is derived from the mime type of the file, when available.