codemelted.js Module
    Preparing search index...

    Function disk_read_file

    • Brings up a file chooser to select a file to read its data for later use.

      Parameters

      • params: { accept?: string; data_type: string }

        The named parameters.

        • Optionalaccept?: string

          A comma separated list of either file extensions or mime types representing files

        • data_type: string

          The type of data being saved to disk.

      Returns Promise<CResult<string | ArrayBuffer | Uint8Array<ArrayBufferLike> | null>>

      The data read from the particular file or null if an error occurred or no file was selected. A rejected promise represents a module API violation.

      // Read a text file from disk.
      const data = await disk_read_file({
      data_type: DISK_DATA_TYPE.Text,
      accept: "*.txt"
      });
      if (data) {
      // Do something with the data.
      // Could be null if you don't select a file.
      }