FileSystemUtils API
showOpenFilePicker()
Show open file picker dialog.
type:
function
tstype showOpenFilePickFn = (options: OpenFilePickerOptions) => Promise<MockFileSystemFileHandle[]>;
example
tsimport { FileSystemUtils } from "@shihongxins/utils"; FileSystemUtils.showOpenFilePicker({ multiple: true, excludeAcceptAllOption: true, types: [ { description: "Media", accept: { "image/*": [".png", ".jpg", ".jpeg", ".gif", ".apng", ".webp"], "audio/*": [".mp3", ".flac"], } } { description: "Text", accept: { "text/*": [".txt"], "html/*": [".html", ".htm", ".xhtml", ".xml"], } } ] });
showDirectoryPicker()
Show open directory picker dialog.
type:
function
tstype showDirectoryPickerFn = (options: DirectoryPickerOptions) => Promise<MockFileSystemDirectoryHandle>;
example
tsimport { FileSystemUtils } from "@shihongxins/utils"; FileSystemUtils.showDirectoryPickerFn({ mode: "read", startIn: "desktop", native: true, });
downloadFile()
Download a file by File or URL.
type:
function
tsfunction downloadFile(target: string | Blob, filename?: string, newWnd?: boolean): void | never;
example
tsimport { FileSystemUtils } from "@shihongxins/utils"; const txt = new Blob(["Hello world"], { type: "text/plain" }); FileSystemUtils.downloadFile(txt, "hi.txt");