H5P NodeJS Library
    Preparing search index...

    Keeps track of temporary files (images, video etc. upload for unsaved content).

    Index

    Constructors

    Methods

    • Saves a file to temporary storage. Assigns access permission to the user passed as an argument only.

      Parameters

      • filename: string

        the original filename of the file to store

      • dataStream: ReadStream

        the data of the file in a readable stream

      • user: IUser

        the user who requests the file

      Returns Promise<string>

      the new filename (not equal to the filename passed to the method to unsure uniqueness)

    • Removes a file from temporary storage. Will silently do nothing if the file does not exist or is not accessible.

      Parameters

      • filename: string
      • user: IUser

      Returns Promise<void>

    • Checks if a file exists in temporary storage.

      Parameters

      • filename: string

        the filename to check; can be a path including subdirectories (e.g. 'images/xyz.png')

      • user: IUser

        the user for who to check

      Returns Promise<boolean>

      true if file already exists

    • Tries generating a unique filename for the file by appending a id to it. Checks in storage if the filename already exists and tries again if necessary. Throws an H5PError if no filename could be determined.

      Parameters

      • filename: string

        the filename to check

      • user: IUser

        the user who is saving the file

      Returns Promise<string>

      the unique filename

    • Returns a information about a temporary file. Throws an exception if the file does not exist.

      Parameters

      • filename: string

        the relative path inside the library

      • user: IUser

        the user who wants to access the file

      Returns Promise<IFileStats>

      the file stats

    • Returns a file stream for temporary file. Will throw H5PError if the file doesn't exist or the user has no access permissions! Make sure to close this stream. Otherwise the temporary files can't be deleted properly!

      Parameters

      • filename: string

        the file to get

      • user: IUser

        the user who requests the 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>

      a stream to read from