Package io.jmix.core

Interface FileStorage

All Known Implementing Classes:
AwsFileStorage, LocalFileStorage

public interface FileStorage
Interface of a component to store and load files defined by file references.
  • Method Details

    • getStorageName

      String getStorageName()
      Returns the name of this storage, which will be saved in FileRefs.

      Each file storage in the application should have a unique name.

    • saveStream

      FileRef saveStream(String fileName, InputStream inputStream)
      Saves an InputStream contents into the file storage.
      Parameters:
      fileName - file name
      inputStream - input stream, must be closed in the calling code
      Returns:
      file reference
      Throws:
      IllegalArgumentException - if arguments are incorrect
      FileStorageException - if something goes wrong
    • openStream

      InputStream openStream(FileRef reference)
      Returns an input stream to load a file contents.
      Parameters:
      reference - file reference
      Returns:
      input stream, must be closed after use
      Throws:
      IllegalArgumentException - if arguments are incorrect
      FileStorageException - if something goes wrong
    • removeFile

      void removeFile(FileRef reference)
      Removes a file from the file storage.
      Parameters:
      reference - file reference
      Throws:
      IllegalArgumentException - if file reference is invalid
    • fileExists

      boolean fileExists(FileRef reference)
      Tests whether the file denoted by this file reference exists.
      Parameters:
      reference - file reference
      Returns:
      true if the file denoted by this file reference exists
      Throws:
      IllegalArgumentException - if file reference is invalid