Package mops.persistence
Class FileRepository
- java.lang.Object
-
- mops.persistence.FileRepository
-
@Repository @AggregateBuilder public class FileRepository extends java.lang.Object
MinIO connection.
-
-
Constructor Summary
Constructors Constructor Description FileRepository(FileRepositoryConfig configuration)Connects to MinIO Server and checks if the bucket exists.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeleteFile(long fileId)Deletes a file permanently.booleanfileExist(long fileId)Checks if a file with a specified ID already exists.java.util.Set<java.lang.Long>getAllIds()Fetches all IDs.java.io.InputStreamgetFileContent(long fileId)Retrieves the bytes of the file.voidsaveFile(java.io.InputStream stream, long size, java.lang.String type, long fileId)Saves an input stream with meta information.voidsaveFile(org.springframework.web.multipart.MultipartFile file, long fileId)Saves a file.
-
-
-
Constructor Detail
-
FileRepository
public FileRepository(FileRepositoryConfig configuration) throws StorageException
Connects to MinIO Server and checks if the bucket exists.- Parameters:
configuration- the injected Config.- Throws:
StorageException- on Error
-
-
Method Detail
-
saveFile
public void saveFile(org.springframework.web.multipart.MultipartFile file, long fileId) throws StorageExceptionSaves a file.- Parameters:
file- the file that should get saved permanently.fileId- the File ID given by the FileInfo database.- Throws:
StorageException- on Error
-
saveFile
public void saveFile(java.io.InputStream stream, long size, java.lang.String type, long fileId) throws StorageExceptionSaves an input stream with meta information.- Parameters:
stream- input stream (must be closed by caller)size- size in bytestype- content typefileId- the File ID given by the FileInfo database.- Throws:
StorageException- on Error
-
deleteFile
public void deleteFile(long fileId) throws StorageExceptionDeletes a file permanently.- Parameters:
fileId- the ID of the file that's desired to be deleted.- Throws:
StorageException- on error
-
getFileContent
public java.io.InputStream getFileContent(long fileId) throws StorageExceptionRetrieves the bytes of the file.- Parameters:
fileId- the ID of the file that's desired to be returned.- Returns:
- file content as byte array
- Throws:
StorageException- on error
-
fileExist
public boolean fileExist(long fileId) throws StorageExceptionChecks if a file with a specified ID already exists.- Parameters:
fileId- the file ID- Returns:
- true if found
- Throws:
StorageException
-
getAllIds
public java.util.Set<java.lang.Long> getAllIds() throws StorageExceptionFetches all IDs.- Returns:
- all File IDs
- Throws:
StorageException
-
-