H5P NodeJS Library
    Preparing search index...

    The ContentManager takes care of saving content and dependent files. It only contains storage-agnostic functionality and depends on a ContentStorage object to do the actual persistence.

    Index

    Constructors

    Properties

    contentStorage: IContentStorage

    The storage object

    contentUserDataStorage?: IContentUserDataStorage

    The contentUserDataStorage to delete contentUserData for content when it is deleted

    Methods

    • Adds a content file to an existing content object. The content object has to be created with createContent(...) first.

      Parameters

      • contentId: string

        The id of the content to add the file to

      • filename: string

        The name of the content file

      • stream: Stream

        A readable stream that contains the data

      • user: IUser

        The user who owns this object

      Returns Promise<void>

    • Checks if a piece of content exists.

      Parameters

      • contentId: string

        the content to check

      Returns Promise<boolean>

      true if the piece of content exists

    • Checks if a file exists.

      Parameters

      • contentId: string

        The id of the content to add the file to

      • filename: string

        the filename of the file to get

      Returns Promise<boolean>

      true if the file exists

    • Creates a content object in the repository. Add files to it later with addContentFile(...).

      Parameters

      • metadata: IContentMetadata

        The metadata of the content (= h5p.json)

      • content: any

        the content object (= content/content.json)

      • user: IUser

        The user who owns this object.

      • OptionalcontentId: string

        (optional) The content id to use

      Returns Promise<string>

      The newly assigned content id

    • Deletes a piece of content, the corresponding contentUserData and all files dependent on it.

      Parameters

      • contentId: string

        the piece of content to delete

      • user: IUser

        the user who wants to delete it

      Returns Promise<void>

    • Deletes a file from a content object.

      Parameters

      • contentId: string

        the content object the file is attached to

      • filename: string

        the file to delete

      • Optionaluser: IUser

      Returns Promise<void>

    • Returns a readable stream of a content file (e.g. image or video) inside a piece of content

      Parameters

      • contentId: string

        the id of the content object that the file is attached to

      • filename: string

        the filename of the file to get

      • user: IUser

        the user who wants to retrieve the content file

      • OptionalrangeStart: number

        (optional) the position in bytes at which the stream should start

      • OptionalrangeEnd: number

        (optional) the position in bytes at which the stream should end

      Returns Promise<Readable>

    • Returns the content object (=contents of content/content.json) of a piece of content.

      Parameters

      • contentId: string

        the content id

      • user: IUser

        The user who wants to access the content

      Returns Promise<any>

    • Lists the content objects in the system (if no user is specified) or owned by the user.

      Parameters

      • Optionaluser: IUser

        (optional) the user who owns the content

      Returns Promise<string[]>

      a list of contentIds

    • Gets the filenames of files added to the content with addContentFile(...) (e.g. images, videos or other files)

      Parameters

      • contentId: string

        the piece of content

      • user: IUser

        the user who wants to access the piece of content

      Returns Promise<string[]>

      a list of files that are used in the piece of content, e.g. ['image1.png', 'video2.mp4']

    • Parameters

      • filename: string

      Returns string