Menu

class: File

[22:14] (extern: com.aussom.aussomscript.AFile) extends: object

The File class represents a single file selected by the user through an input[type=file] element. It exposes the file's metadata and provides callback-based read methods for the file's content.

Methods

  • getName ()

    Returns the file's base name, for example "photo.jpg".

    • @r A string with the file name.
  • getLastModified ()

    Returns the last-modified timestamp as milliseconds since the Unix epoch (January 1, 1970 00:00:00 UTC).

    • @r A double with the timestamp in milliseconds.
  • getSize ()

    Returns the size of the file in bytes.

    • @r An int with the file size.
  • getType ()

    Returns the MIME type of the file (e.g. "image/jpeg"), or an empty string if the browser could not determine the type.

    • @r A string with the MIME type.
  • readText (callback OnComplete)

    Reads the entire file as a UTF-8 text string and invokes OnComplete with the resulting string when the read finishes.

    • @p OnComplete is a callback invoked with the file content as a string.
  • readBytes (callback OnComplete)

    Reads the entire file as raw bytes and invokes OnComplete with an Aussom buffer object when the read finishes. Use this method for binary files such as images or PDFs.

    • @p OnComplete is a callback invoked with a buffer containing the file bytes.
  • readDataUrl (callback OnComplete)

    Reads the entire file and invokes OnComplete with a data: URL string that encodes the file contents. Useful for embedding binary files directly in HTML attributes such as img src.

    • @p OnComplete is a callback invoked with the data: URL string.