API for working with the files in the app directory.

interface IAppFilesApi {
    _apiId: "mendix.AppFilesApi";
    addEventListener<K>(eventType: K, listener: EventHandler<{}, K>): DisposeListener;
    deleteFile(path: string): Promise<void>;
    getFile(path: string): Promise<string>;
    putFile(path: string, content: string): Promise<void>;
    removeEventListener<K>(eventType: K, listener: EventHandler<{}, K>): void;
}

Hierarchy (view full)

Properties

_apiId

Unique identifier that can be used to register or retrieve a specific API.

Example: mendix.EditorsAPI, mycompany.MyFunkyAPI

Methods

  • Adds an event listener for the specified event type.

    Type Parameters

    • K extends never

    Parameters

    • eventType: K

      The type of event to listen for.

    • listener: EventHandler<{}, K>

      The event listener to add.

    Returns DisposeListener

    A function that can be called to remove the event listener.

  • Deletes the file at the specified path.

    Parameters

    • path: string

      The relative path of the file to delete.

    Returns Promise<void>

    A promise that resolves when the file has been deleted.

  • Retrieves the content of a file at the specified path.

    Parameters

    • path: string

      The relative path of the file to retrieve.

    Returns Promise<string>

    A promise that resolves with the content of the file.

  • Uploads content to a file at the specified path.

    Parameters

    • path: string

      The relative path of the file to upload content to.

    • content: string

      The content to upload to the file.

    Returns Promise<void>

    A promise that resolves when the file has been uploaded.

  • Removes an event listener for the specified event type.

    Type Parameters

    • K extends never

    Parameters

    • eventType: K

      The type of event to remove the listener from.

    • listener: EventHandler<{}, K>

      The event listener to remove.

    Returns void