Class LoadVideoFromGridFS

java.lang.Object
backend.speech.LoadVideoFromGridFS

public class LoadVideoFromGridFS extends Object
Class for loading video files from MongoDB GridFS. Modified to use the connection pool.
Author:
Kai
  • Constructor Details

    • LoadVideoFromGridFS

      public LoadVideoFromGridFS(MongoDBHandler mongoDbHandler)
      Constructor that takes a specific MongoDB handler
      Parameters:
      mongoDbHandler - The MongoDB handler to use
    • LoadVideoFromGridFS

      public LoadVideoFromGridFS()
      Default constructor that uses the pooled connection
  • Method Details

    • main

      public static void main(String[] args)
      Example usage of this class.
    • loadVideo

      public byte[] loadVideo(org.bson.types.ObjectId videoId) throws IOException
      Loads a video file by its GridFS ID and returns it as a byte array.
      Parameters:
      videoId - The ObjectId of the video file in GridFS
      Returns:
      The byte array of the file
      Throws:
      IOException - If an I/O error occurs
    • getVideoBase64

      public HashMap<String,String> getVideoBase64(Speech_impl speechImpl) throws IOException
      Retrieves a video from GridFS and returns it as a Base64-encoded string with its MIME type.
      Parameters:
      speechImpl - The speech implementation containing video info
      Returns:
      HashMap containing the Base64-encoded video and its MIME type
      Throws:
      IOException - If an I/O error occurs
    • getSpeechDAO

      public SpeechDAO getSpeechDAO()
      Get the speech DAO instance.
      Returns:
      The SpeechDAO instance