the S3 content storage; Must be either set to a bucket or the bucket must be specified in the options!
a MongoDB collection (read- and writable)
options
Optional
invalidCharactersRegexp?: RegExpThese characters will be removed from files that are saved to S3. There is a very strict default list that basically only leaves alphanumeric filenames intact. Should you need more relaxed settings you can specify them here.
Optional
maxKeyLength?: numberIndicates how long keys in S3 can be. Defaults to 1024. (S3 supports 1024 characters, other systems such as Minio might only support 255 on Windows).
Optional
s3Acl?: ObjectCannedACLThe ACL to use for uploaded content files. Defaults to private.
The bucket to upload to and download from. (required)
Creates or updates a content object in the repository. Throws an error if something went wrong.
The 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. Throws an error if something went wrong.
The id of the content to add the file to
The filename
A readable stream that contains the data
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.
The content id to delete.
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
Optional
user: IUserChecks if a file exists.
The id of the content to add the file to
the filename of the file to get
true if the file exists
Returns information about a content file (e.g. image or video) inside a piece of content.
the filename of the file to get information about
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 Note: Make sure to handle the 'error' event of the Readable! This method does not check if the file exists in storage to avoid the extra request. However, this means that there will be an error when piping the Readable to the response if the file doesn't exist!
the id of the content object that the file is attached to
the filename of the file to get
the user who wants to retrieve the content file
Optional
rangeStart: numberOptional
rangeEnd: numberReturns 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 addContentFile(...) (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. ['image1.png', 'video2.mp4']
Removes invalid characters from filenames and enforces other filename rules required by the storage implementation (e.g. filename length restrictions).
the filename to sanitize; this can be a relative path (e.g. "images/image1.png")
the clean filename
This storage implementation stores content data in a MongoDB collection and a S3 bucket. The parameters and metadata of a H5P content object are stored in MongoDB, while all files are put into S3 storage.