Interface I_CmsS3Client
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
CmsGenericS3Client
Provides a simplified abstraction for interacting with S3-compatible storage backends like MinIO or AWS S3.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceVisitor for S3 object keys.static interfaceVisitor for S3 object metadata.static interfaceVisitor for S3 objects. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()Closes the client and releases associated resources.voiddeleteObject(String key) Deletes an object from the specified bucket.default CmsS3DeleteResultdeleteObjects(List<String> keys) Deletes multiple objects.booleanChecks if an object exists in the specified bucket.byte[]Retrieves an object's content from the specified bucket.default longgetObjectLength(String key) Returns the length of an object's content.default longReturns the length of an object's content if the object exists.default CmsS3ObjectMetadatagetObjectMetadata(String key) Returns an object's metadata.voidUploads an object to the specified bucket.default voidreadObjectFrom(String key, I_CmsFileContentStreamHandler handler) Passes an object's content from the specified bucket to the given input stream handler.default booleanrenewObject(String key, String expectedRevision, Instant renewalTime) Renews an object by conditionally copying it onto itself.default voidValidates that the configured bucket is accessible.default voidVisits all object keys in the configured bucket.default voidvisitObjects(String prefix, I_CmsS3Client.I_CmsS3ObjectMetadataVisitor visitor) Visits object metadata for objects matching an optional prefix.default voidVisits all objects in the configured bucket.default voidwriteObjectRangeTo(String key, long start, long length, OutputStream out) Writes an object byte range from the specified bucket to the given output stream.default CmsS3ObjectMetadatawriteObjectRangeToWithMetadata(String key, long start, long length, OutputStream out) Writes an object byte range and returns the metadata received with the object response.default voidwriteObjectTo(String key, OutputStream out) Writes an object's content from the specified bucket to the given output stream.default CmsS3ObjectMetadatawriteObjectToWithMetadata(String key, OutputStream out) Writes an object's content and returns the metadata received with the object response.
-
Method Details
-
close
Closes the client and releases associated resources.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception- if closing the client fails
-
deleteObject
Deletes an object from the specified bucket.- Parameters:
key- the identifier for the object to delete- Throws:
Exception- if the deletion fails
-
deleteObjects
Deletes multiple objects.The optimized S3 implementation supports at most 1000 keys per call. This default implementation preserves compatibility for other clients.
- Parameters:
keys- the object keys- Returns:
- the per-object delete result
- Throws:
Exception- if the complete request fails
-
exists
Checks if an object exists in the specified bucket.- Parameters:
key- the identifier for the object- Returns:
- true if the object exists, false otherwise
- Throws:
Exception- if the existence check fails
-
getObject
Retrieves an object's content from the specified bucket.- Parameters:
key- the identifier for the object- Returns:
- the binary data of the object
- Throws:
Exception- if the object cannot be retrieved or does not exist
-
getObjectLength
Returns the length of an object's content.- Parameters:
key- the identifier for the object- Returns:
- the object content length
- Throws:
Exception- if the object can not be accessed
-
getObjectLengthIfExists
Returns the length of an object's content if the object exists.- Parameters:
key- the identifier for the object- Returns:
- the object content length, or
-1if the object does not exist - Throws:
Exception- if the object can not be accessed
-
getObjectMetadata
Returns an object's metadata.- Parameters:
key- the identifier for the object- Returns:
- the object metadata
- Throws:
Exception- if the object can not be accessed
-
putObject
Uploads an object to the specified bucket.- Parameters:
key- the unique identifier (path) for the objectcontent- the binary data to upload- Throws:
Exception- if the upload fails
-
readObjectFrom
Passes an object's content from the specified bucket to the given input stream handler.- Parameters:
key- the identifier for the objecthandler- the stream handler- Throws:
Exception- if the object cannot be retrieved or handled
-
renewObject
default boolean renewObject(String key, String expectedRevision, Instant renewalTime) throws Exception Renews an object by conditionally copying it onto itself.The copy must only be applied when the source still has the expected revision. A missing object or revision mismatch is not an error and is reported by returning
false. The S3 last-modified time is always assigned by the storage server.- Parameters:
key- the object keyexpectedRevision- the expected source revisionrenewalTime- the requested renewal time- Returns:
trueif the object was renewed, orfalseif it no longer matched- Throws:
Exception- if the copy fails
-
validateBucketAccess
Validates that the configured bucket is accessible.- Throws:
Exception- if the bucket can not be accessed
-
visitObjectKeys
Visits all object keys in the configured bucket.- Parameters:
visitor- the object key visitor- Throws:
Exception- if listing fails
-
visitObjects
Visits all objects in the configured bucket.- Parameters:
visitor- the object visitor- Throws:
Exception- if listing fails
-
visitObjects
default void visitObjects(String prefix, I_CmsS3Client.I_CmsS3ObjectMetadataVisitor visitor) throws Exception Visits object metadata for objects matching an optional prefix.This compatibility implementation filters client-side and can not provide timestamps or revisions. Optimized clients should override it.
- Parameters:
prefix- the object key prefix, ornullvisitor- the metadata visitor- Throws:
Exception- if listing fails
-
writeObjectRangeTo
default void writeObjectRangeTo(String key, long start, long length, OutputStream out) throws Exception Writes an object byte range from the specified bucket to the given output stream.- Parameters:
key- the identifier for the objectstart- the first byte to writelength- the number of bytes to writeout- the output stream to write to- Throws:
Exception- if the object cannot be retrieved or written
-
writeObjectRangeToWithMetadata
default CmsS3ObjectMetadata writeObjectRangeToWithMetadata(String key, long start, long length, OutputStream out) throws Exception Writes an object byte range and returns the metadata received with the object response.Optimized clients should override this method so that no additional metadata request is needed. The default implementation preserves compatibility by reading the range first and loading the metadata afterwards.
- Parameters:
key- the identifier for the objectstart- the first byte to writelength- the number of bytes to writeout- the output stream to write to- Returns:
- the object metadata
- Throws:
Exception- if the object cannot be retrieved or written
-
writeObjectTo
Writes an object's content from the specified bucket to the given output stream.- Parameters:
key- the identifier for the objectout- the output stream to write to- Throws:
Exception- if the object cannot be retrieved or written
-
writeObjectToWithMetadata
default CmsS3ObjectMetadata writeObjectToWithMetadata(String key, OutputStream out) throws Exception Writes an object's content and returns the metadata received with the object response.Optimized clients should override this method so that no additional metadata request is needed. The default implementation preserves compatibility by reading the object first and loading the metadata afterwards.
- Parameters:
key- the identifier for the objectout- the output stream to write to- Returns:
- the object metadata
- Throws:
Exception- if the object cannot be retrieved or written
-