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 void
deleteFile(long fileId)
Deletes a file permanently.boolean
fileExist(long fileId)
Checks if a file with a specified ID already exists.java.util.Set<java.lang.Long>
getAllIds()
Fetches all IDs.java.io.InputStream
getFileContent(long fileId)
Retrieves the bytes of the file.void
saveFile(java.io.InputStream stream, long size, java.lang.String type, long fileId)
Saves an input stream with meta information.void
saveFile(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 StorageException
Saves 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 StorageException
Saves 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 StorageException
Deletes 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 StorageException
Retrieves 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 StorageException
Checks 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 StorageException
Fetches all IDs.- Returns:
- all File IDs
- Throws:
StorageException
-
-