Interface GridFsRepository

All Known Implementing Classes:
EncryptedGridFsRepositoryImpl, GridFsRepositoryImpl

public interface GridFsRepository
Abstraction for storing binary content in MongoDB's GridFS bucket. Provides basic CRUD operations along with helper methods for metadata management and hash calculation.
  • Method Details

    • saveFile

      void saveFile(InputStream inputStream, String fileName, String contentType, Map<String,String> metadata)
      Stores the provided stream as a file.
      Parameters:
      inputStream - the file content
      fileName - the file name to persist
      contentType - MIME type associated with the file
      metadata - metadata key/value pairs
    • updateFileMetadata

      void updateFileMetadata(String uuid, Map<String,String> metadata)
      Updates metadata for an existing stored file.
      Parameters:
      uuid - identifier of the file
      metadata - metadata to merge with the existing entry
    • findFileById

      com.mongodb.client.gridfs.model.GridFSFile findFileById(String uuid)
      Retrieves a file descriptor by UUID.
      Parameters:
      uuid - identifier of the file
      Returns:
      the matching GridFSFile or null
    • deleteFileById

      void deleteFileById(String uuid)
      Removes a file and its metadata from GridFS.
      Parameters:
      uuid - identifier of the file
    • computeHash

      String computeHash(String uuid, String algorithm)
      Calculates the cryptographic hash of a stored file.
      Parameters:
      uuid - identifier of the file
      algorithm - name of the hash algorithm (e.g. MD5 or SHA-256)
      Returns:
      the hexadecimal encoded hash value