Class FileRepository


  • @Repository
    @AggregateBuilder
    public class FileRepository
    extends java.lang.Object
    MinIO connection.
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 bytes
        type - content type
        fileId - 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