Package org.codelibs.fess.storage
Class S3StorageClient
java.lang.Object
org.codelibs.fess.storage.S3StorageClient
- All Implemented Interfaces:
AutoCloseable,StorageClient
S3-compatible storage client implementation using AWS SDK v2.
Supports Amazon S3, MinIO, and other S3-compatible storage systems.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the client and releases resources.voiddeleteObject(String objectName) Deletes an object from storage.voiddownloadObject(String objectName, OutputStream outputStream) Downloads an object from storage.voidEnsures the bucket exists, creating it if necessary.getObjectTags(String objectName) Gets tags/metadata for an object.booleanChecks if storage is properly configured and accessible.listObjects(String prefix, int maxItems) Lists objects in storage with the given prefix.voidsetObjectTags(String objectName, Map<String, String> tags) Sets tags/metadata for an object.voiduploadObject(String objectName, InputStream inputStream, long size, String contentType) Uploads an object to storage.
-
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 keysecretKey- the AWS secret keybucket- the bucket nameregion- the AWS region
-
-
Method Details
-
uploadObject
Description copied from interface:StorageClientUploads an object to storage.- Specified by:
uploadObjectin interfaceStorageClient- Parameters:
objectName- the name/path for the objectinputStream- the input stream of data to uploadsize- the size of the data in bytescontentType- the MIME type of the content
-
downloadObject
Description copied from interface:StorageClientDownloads an object from storage.- Specified by:
downloadObjectin interfaceStorageClient- Parameters:
objectName- the name/path of the object to downloadoutputStream- the output stream to write data to
-
deleteObject
Description copied from interface:StorageClientDeletes an object from storage.- Specified by:
deleteObjectin interfaceStorageClient- Parameters:
objectName- the name/path of the object to delete
-
listObjects
Description copied from interface:StorageClientLists objects in storage with the given prefix.- Specified by:
listObjectsin interfaceStorageClient- 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
Description copied from interface:StorageClientGets tags/metadata for an object.- Specified by:
getObjectTagsin interfaceStorageClient- Parameters:
objectName- the name/path of the object- Returns:
- map of tag key-value pairs
-
setObjectTags
Description copied from interface:StorageClientSets tags/metadata for an object.- Specified by:
setObjectTagsin interfaceStorageClient- Parameters:
objectName- the name/path of the objecttags- the tags to set
-
ensureBucketExists
public void ensureBucketExists()Description copied from interface:StorageClientEnsures the bucket exists, creating it if necessary.- Specified by:
ensureBucketExistsin interfaceStorageClient
-
isAvailable
public boolean isAvailable()Description copied from interface:StorageClientChecks if storage is properly configured and accessible.- Specified by:
isAvailablein interfaceStorageClient- Returns:
- true if storage is available
-
close
public void close()Description copied from interface:StorageClientCloses the client and releases resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStorageClient
-