Class S3StorageClient

java.lang.Object
org.codelibs.fess.storage.S3StorageClient
All Implemented Interfaces:
AutoCloseable, StorageClient

public class S3StorageClient extends Object implements StorageClient
S3-compatible storage client implementation using AWS SDK v2. Supports Amazon S3, MinIO, and other S3-compatible storage systems.
  • Constructor Details

    • S3StorageClient

      public S3StorageClient(String endpoint, String accessKey, String secretKey, String bucket, String region)
      Creates a new S3StorageClient instance.
      Parameters:
      endpoint - the S3 endpoint URL (null for AWS default)
      accessKey - the AWS access key
      secretKey - the AWS secret key
      bucket - the bucket name
      region - the AWS region
  • Method Details

    • uploadObject

      public void uploadObject(String objectName, InputStream inputStream, long size, String contentType)
      Description copied from interface: StorageClient
      Uploads an object to storage.
      Specified by:
      uploadObject in interface StorageClient
      Parameters:
      objectName - the name/path for the object
      inputStream - the input stream of data to upload
      size - the size of the data in bytes
      contentType - the MIME type of the content
    • downloadObject

      public void downloadObject(String objectName, OutputStream outputStream)
      Description copied from interface: StorageClient
      Downloads an object from storage.
      Specified by:
      downloadObject in interface StorageClient
      Parameters:
      objectName - the name/path of the object to download
      outputStream - the output stream to write data to
    • deleteObject

      public void deleteObject(String objectName)
      Description copied from interface: StorageClient
      Deletes an object from storage.
      Specified by:
      deleteObject in interface StorageClient
      Parameters:
      objectName - the name/path of the object to delete
    • listObjects

      public List<StorageItem> listObjects(String prefix, int maxItems)
      Description copied from interface: StorageClient
      Lists objects in storage with the given prefix.
      Specified by:
      listObjects in interface StorageClient
      Parameters:
      prefix - the path prefix to list objects under (null or empty for root)
      maxItems - maximum number of items to return
      Returns:
      list of storage items
    • getObjectTags

      public Map<String,String> getObjectTags(String objectName)
      Description copied from interface: StorageClient
      Gets tags/metadata for an object.
      Specified by:
      getObjectTags in interface StorageClient
      Parameters:
      objectName - the name/path of the object
      Returns:
      map of tag key-value pairs
    • setObjectTags

      public void setObjectTags(String objectName, Map<String,String> tags)
      Description copied from interface: StorageClient
      Sets tags/metadata for an object.
      Specified by:
      setObjectTags in interface StorageClient
      Parameters:
      objectName - the name/path of the object
      tags - the tags to set
    • ensureBucketExists

      public void ensureBucketExists()
      Description copied from interface: StorageClient
      Ensures the bucket exists, creating it if necessary.
      Specified by:
      ensureBucketExists in interface StorageClient
    • isAvailable

      public boolean isAvailable()
      Description copied from interface: StorageClient
      Checks if storage is properly configured and accessible.
      Specified by:
      isAvailable in interface StorageClient
      Returns:
      true if storage is available
    • close

      public void close()
      Description copied from interface: StorageClient
      Closes the client and releases resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface StorageClient