Class SwiftFileStore

java.lang.Object
io.github.qubitpi.athena.filestore.swift.SwiftFileStore
All Implemented Interfaces:
FileStore

@Singleton @NotThreadSafe public class SwiftFileStore extends Object implements FileStore
An OpenStack Swift implementation of FileStore.
  • Field Details

    • DEFAULT_CONTAINER

      public static final String DEFAULT_CONTAINER
      The container name where all files are going to be stored in.
      See Also:
  • Constructor Details

    • SwiftFileStore

      @Inject public SwiftFileStore(@NotNull @NotNull org.javaswift.joss.model.Account account, @NotNull @NotNull FileIdGenerator fileIdGenerator)
      DI constructor.
      Parameters:
      account - A Swift client allowing access to the various containers underneath it. Note that you need to call Account.getContainer(String) to work on Containers and then pass the Account into this constructor. The method returns a stub for dealing with Containers, but does not create a container in the Object Store. The creation only takes place when you run the Container.create() method on a Container. Information on the container will not be retrieved until the time you actually call on that information - ie, information is lazily loaded.
      fileIdGenerator - An object that provides file unique identifiers
      Throws:
      NullPointerException - if any constructor argument is null
  • Method Details

    • upload

      public String upload(File file)
      Description copied from interface: FileStore
      Persists a file into object storage database.

      Note that calling this method does NOT automatically update the managed metadata of this file in MetaStore. The metadata must be saved separately using MetaStore.saveMetaData(String, MetaData).

      The implementation does NOT have to be thread-safe. FileStore assumes that it is the callers' responsibilities to implement the thread safety themselves.

      Specified by:
      upload in interface FileStore
      Parameters:
      file - An object representing the file to be persisted
      Returns:
      the file ID that can be used later to retrieve that file in Athena
    • download

      public InputStream download(String fileId)
      Description copied from interface: FileStore
      Retrieves a file identified by a specified file ID from object storage.
      Specified by:
      download in interface FileStore
      Parameters:
      fileId - The provided file ID, which is the same as the return value of FileStore.upload(File)
      Returns:
      a previously uploaded file stream