H5P NodeJS Library
    Preparing search index...

    Handles the installation of libraries and saving of content from a H5P package.

    Index

    Constructors

    Methods

    • Permanently adds content from a H5P package to the system. This means that content is permanently added to storage and necessary libraries are installed from the package if they are not already installed.

      This is NOT what you want if the user is just uploading a package in the editor client!

      Throws errors if something goes wrong.

      Parameters

      • packagePath: string

        The full path to the H5P package file on the local disk.

      • user: IUser

        The user who wants to upload the package.

      • OptionalcontentId: string

        (optional) the content id to use for the package

      Returns Promise<
          {
              id: string;
              installedLibraries: ILibraryInstallResult[];
              metadata: IContentMetadata;
              parameters: any;
          },
      >

      the newly assigned content id, the metadata (=h5p.json) and parameters (=content.json) inside the package and a list of installed libraries.

      The method should not be used as it anymore, as there might be issues with invalid filenames!

    • Copies files inside the package into temporary storage and installs the necessary libraries from the package if they are not already installed. (This is what you want to do if the user uploads a package in the editor client.) Pass the information returned about the content back to the editor client. Throws errors if something goes wrong.

      Parameters

      • packagePath: string

        The full path to the H5P package file on the local disk.

      • user: IUser

        The user who wants to upload the package.

      Returns Promise<
          {
              installedLibraries: ILibraryInstallResult[];
              metadata: IContentMetadata;
              parameters: any;
          },
      >

      the metadata and parameters inside the package and a list of installed libraries

    • Installs all libraries from the package. Assumes that the user calling this has the permission to install libraries! Throws errors if something goes wrong.

      Parameters

      • packagePath: string

        The full path to the H5P package file on the local disk.

      Returns Promise<ILibraryInstallResult[]>

      a list of the installed libraries

    • Extracts a H5P package to the specified directory.

      Parameters

      • packagePath: string

        The full path to the H5P package file on the local disk

      • directoryPath: string

        The full path of the directory to which the package should be extracted

      • options: { includeContent: boolean; includeLibraries: boolean; includeMetadata: boolean } = ...
        • includeContent: boolean

          If true, the content folder inside the package will be extracted.

        • includeLibraries: boolean

          If true, the library directories inside the package will be extracted.

        • includeMetadata: boolean

          If true, the h5p.json file inside the package will be extracted.

      Returns Promise<void>