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

      default 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
    • saveStream

      FileRef saveStream(String fileName, InputStream inputStream, Map<String,Object> parameters)
      Saves an InputStream contents into the file storage using additional parameters.
      Parameters:
      fileName - file name
      inputStream - input stream, must be closed in the calling code
      parameters - additional parameters that can be used in specific storage implementation (for example, can be converted to FileRef parameters)
      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