Creates a content object in the repository. Content files (like images) are added to it later with addFile(...). Throws an error if something went wrong. In this case the calling method will remove all traces of the content and all changes are reverted.
The content metadata of the content (= h5p.json)
the content object (= content/content.json)
The user who owns this object.
Optional
contentId: string(optional) The content id to use
The newly assigned content id
Adds a content file to an existing content object. The content object has to be created with addContent(...) first.
The id of the content to add the file to
The filename; can be a path including subdirectories (e.g. 'images/xyz.png')
A readable stream that contains the data
Optional
user: IUser(optional) The user who owns this object
Checks if a piece of content exists in storage.
the content id to check
true if the piece of content exists
Deletes a content object and all its dependent files from the repository. Throws errors if something goes wrong.
Optional
user: IUserThe user who wants to delete the content
Deletes a file from a content object.
the content object the file is attached to
the file to delete; can be a path including subdirectories (e.g. 'images/xyz.png')
Optional
user: IUserChecks if a file exists.
The id of the content to add the file to
the filename of the file to get; can be a path including subdirectories (e.g. 'images/xyz.png')
true if the file exists
Returns information about a content file (e.g. image or video) inside a piece of content.
the user who wants to retrieve the content file
Returns a readable stream of a content file (e.g. image or video) inside a piece of content
the user who wants to retrieve the content file
Optional
rangeStart: number(optional) the position in bytes at which the stream should start
Optional
rangeEnd: number(optional) the position in bytes at which the stream should end
the stream (that can be used to send the file to the user)
Returns the content metadata (=h5p.json) for a content id
the content id for which to retrieve the metadata
Optional
user: IUser(optional) the user who wants to access the metadata. If undefined, access must be granted.
the metadata
Returns the content object (=content.json) for a content id
the content id for which to retrieve the metadata
Optional
user: IUser(optional) the user who wants to access the metadata. If undefined, access must be granted.
the content object
Calculates how often a library is in use.
the library for which to calculate usage.
asDependency: how often the library is used as subcontent in content; asMainLibrary: how often the library is used as a main library
Lists the content objects in the system (if no user is specified) or owned by the user.
Optional
user: IUser(optional) the user who owns the content
a list of contentIds
Gets the filenames of files added to the content with addFile(...) (e.g. images, videos or other files)
the piece of content
the user who wants to access the piece of content
a list of files that are used in the piece of content, e.g. ['images/image1.png', 'videos/video2.mp4', 'file.xyz']
Optional
sanitizeRemoves invalid characters from filenames and enforces other filename rules required by the storage implementation (e.g. filename length restrictions). Note: file names will be appended with a 9 character long unique id, so you must make sure to shorten long filenames accordingly! If you do not implement this method, there will be no sanitization!
the filename to sanitize; this can be a relative path (e.g. "images/image1.png")
the clean filename
Implementations need to implement the IContentStorage interface and pass it to the constructor of H5PEditor. It is used to persist content data (semantic data, images, videos etc.) permanently. See the FileContentStorage sample implementation in the examples directory for more details.