Package org.saidone.repository
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 Summary
Modifier and TypeMethodDescriptioncomputeHash
(String uuid, String algorithm) Calculates the cryptographic hash of a stored file.void
deleteFileById
(String uuid) Removes a file and its metadata from GridFS.com.mongodb.client.gridfs.model.GridFSFile
findFileById
(String uuid) Retrieves a file descriptor by UUID.void
Stores the provided stream as a file.void
updateFileMetadata
(String uuid, Map<String, String> metadata) Updates metadata for an existing stored file.
-
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 contentfileName
- the file name to persistcontentType
- MIME type associated with the filemetadata
- metadata key/value pairs
-
updateFileMetadata
Updates metadata for an existing stored file.- Parameters:
uuid
- identifier of the filemetadata
- metadata to merge with the existing entry
-
findFileById
Retrieves a file descriptor by UUID.- Parameters:
uuid
- identifier of the file- Returns:
- the matching
GridFSFile
ornull
-
deleteFileById
Removes a file and its metadata from GridFS.- Parameters:
uuid
- identifier of the file
-
computeHash
Calculates the cryptographic hash of a stored file.- Parameters:
uuid
- identifier of the filealgorithm
- name of the hash algorithm (e.g. MD5 or SHA-256)- Returns:
- the hexadecimal encoded hash value
-