Class CmsS3Storage
- All Implemented Interfaces:
AutoCloseable,I_CmsEnumerableStorage,I_CmsStorage,I_CmsStorageDelivery
This implementation stores binary content in an S3-compatible object storage. To ensure high performance for read and write operations, it is highly recommended to use a local object storage (e.g., RustFS or an on-premise S3 appliance) within the same network as the OpenCms application server. Using remote cloud storage may introduce latency that significantly impacts VFS performance.
Content is addressed by its unique hash to support deduplication across different resources.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opencms.db.storage.I_CmsEnumerableStorage
I_CmsEnumerableStorage.I_CmsContentHashVisitor -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe type name of the storage implementation. -
Constructor Summary
ConstructorsConstructorDescriptionCmsS3Storage(String name, String endpoint, String bucketName, String accessKey, String secretKey, boolean pathStyle) Creates a new S3 storage.CmsS3Storage(String name, String endpoint, String bucketName, String accessKey, String secretKey, boolean pathStyle, int connectionTimeout, int socketTimeout, int apiCallAttemptTimeout, int apiCallTimeout, int maxRetries) Creates a new S3 storage.CmsS3Storage(String name, String endpoint, String bucketName, String accessKey, String secretKey, boolean pathStyle, String region, int connectionTimeout, int socketTimeout, int apiCallAttemptTimeout, int apiCallTimeout, int maxRetries) Creates a new S3 storage.CmsS3Storage(String name, CmsS3ClientConfiguration configuration) Creates a new S3 storage. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this storage backend and releases associated resources.voiddeleteContent(CmsDbContext dbc, String hash) Deletes the content from the storage if applicable.Returns the stable storage identifier stored in the VFS content tables.booleanReturns whether path-style access is configured.byte[]loadContent(CmsDbContext dbc, String hash) Loads the actual binary content.voidloadContentFrom(CmsDbContext dbc, String hash, I_CmsFileContentStreamHandler handler) Loads the actual binary content and passes it to the given input stream handler.voidloadContentTo(CmsDbContext dbc, String hash, OutputStream out) Loads the actual binary content into the given output stream.voidstoreContent(CmsDbContext dbc, String hash, byte[] content) Stores the given content.voidstreamRangeTo(CmsDbContext dbc, String hash, long start, long length, OutputStream out) Streams a byte range to the given output stream.voidstreamTo(CmsDbContext dbc, String hash, OutputStream out) Streams the content to the given output stream.booleanReturns if range delivery is supported.voidValidates that the storage backend is available for read and write operations.voidVisits all content hashes stored by this backend.Methods inherited from class org.opencms.db.storage.A_CmsStorage
getHashedPath, validateHash
-
Field Details
-
STORAGE_TYPE
The type name of the storage implementation.- See Also:
-
-
Constructor Details
-
CmsS3Storage
Creates a new S3 storage.- Parameters:
name- the configured backend id used as storage identifierconfiguration- the S3 client configuration
-
CmsS3Storage
public CmsS3Storage(String name, String endpoint, String bucketName, String accessKey, String secretKey, boolean pathStyle) Creates a new S3 storage.- Parameters:
name- the configured backend id used as storage identifierendpoint- the S3 endpointbucketName- the bucket nameaccessKey- the access keysecretKey- the secret keypathStyle- whether path-style access should be used
-
CmsS3Storage
public CmsS3Storage(String name, String endpoint, String bucketName, String accessKey, String secretKey, boolean pathStyle, int connectionTimeout, int socketTimeout, int apiCallAttemptTimeout, int apiCallTimeout, int maxRetries) Creates a new S3 storage.- Parameters:
name- the configured backend id used as storage identifierendpoint- the S3 endpointbucketName- the bucket nameaccessKey- the access keysecretKey- the secret keypathStyle- whether path-style access should be usedconnectionTimeout- the connection timeout in millisecondssocketTimeout- the socket timeout in millisecondsapiCallAttemptTimeout- the timeout for a single API call attempt in millisecondsapiCallTimeout- the timeout for the complete API call in millisecondsmaxRetries- the maximum number of retries
-
CmsS3Storage
public CmsS3Storage(String name, String endpoint, String bucketName, String accessKey, String secretKey, boolean pathStyle, String region, int connectionTimeout, int socketTimeout, int apiCallAttemptTimeout, int apiCallTimeout, int maxRetries) Creates a new S3 storage.- Parameters:
name- the configured backend id used as storage identifierendpoint- the S3 endpointbucketName- the bucket nameaccessKey- the access keysecretKey- the secret keypathStyle- whether path-style access should be usedregion- the AWS regionconnectionTimeout- the connection timeout in millisecondssocketTimeout- the socket timeout in millisecondsapiCallAttemptTimeout- the timeout for a single API call attempt in millisecondsapiCallTimeout- the timeout for the complete API call in millisecondsmaxRetries- the maximum number of retries
-
-
Method Details
-
close
Description copied from interface:I_CmsStorageCloses this storage backend and releases associated resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceI_CmsStorage- Throws:
Exception- if closing the storage backend fails- See Also:
-
deleteContent
Description copied from interface:I_CmsStorageDeletes the content from the storage if applicable.- Specified by:
deleteContentin interfaceI_CmsStorage- Parameters:
dbc- the database contexthash- the SHA-512 content hash- Throws:
Exception- if the deletion in the external storage fails- See Also:
-
getStorageIdentifier
Description copied from interface:I_CmsStorageReturns the stable storage identifier stored in the VFS content tables.The identifier is the configured backend id, for example
mediaorarchive. The database storage uses the reserved backend iddb. The identifier must not depend on mutable connection details such as paths, endpoints, or bucket names.- Specified by:
getStorageIdentifierin interfaceI_CmsStorage- Returns:
- the stable storage identifier
- See Also:
-
isPathStyle
Returns whether path-style access is configured.- Returns:
- true if path-style access is configured
-
loadContent
Description copied from interface:I_CmsStorageLoads the actual binary content.- Specified by:
loadContentin interfaceI_CmsStorage- Parameters:
dbc- the database contexthash- the SHA-512 content hash- Returns:
- the actual binary file content
- Throws:
Exception- if the content cannot be retrieved- See Also:
-
loadContentFrom
public void loadContentFrom(CmsDbContext dbc, String hash, I_CmsFileContentStreamHandler handler) throws Exception Description copied from interface:I_CmsStorageLoads the actual binary content and passes it to the given input stream handler.This default implementation keeps custom storage implementations source compatible by falling back to
I_CmsStorage.loadContent(CmsDbContext, String).- Specified by:
loadContentFromin interfaceI_CmsStorage- Parameters:
dbc- the database contexthash- the SHA-512 content hashhandler- the stream handler- Throws:
Exception- if the content cannot be retrieved or handled- See Also:
-
loadContentTo
Description copied from interface:I_CmsStorageLoads the actual binary content into the given output stream.This default implementation keeps custom storage implementations source compatible by falling back to
I_CmsStorage.loadContent(CmsDbContext, String).- Specified by:
loadContentToin interfaceI_CmsStorage- Parameters:
dbc- the database contexthash- the SHA-512 content hashout- the output stream to write to- Throws:
Exception- if the content cannot be retrieved or written- See Also:
-
storeContent
Description copied from interface:I_CmsStorageStores the given content.- Specified by:
storeContentin interfaceI_CmsStorage- Parameters:
dbc- the database contexthash- the SHA-512 content hashcontent- the actual binary data to store- Throws:
Exception- if the storage operation fails- See Also:
-
streamRangeTo
public void streamRangeTo(CmsDbContext dbc, String hash, long start, long length, OutputStream out) throws Exception Description copied from interface:I_CmsStorageDeliveryStreams a byte range to the given output stream.- Specified by:
streamRangeToin interfaceI_CmsStorageDelivery- Parameters:
dbc- the database contexthash- the SHA-512 content hashstart- the first byte to streamlength- the number of bytes to streamout- the output stream to write to- Throws:
Exception- if streaming fails- See Also:
-
streamTo
Description copied from interface:I_CmsStorageDeliveryStreams the content to the given output stream.- Specified by:
streamToin interfaceI_CmsStorageDelivery- Parameters:
dbc- the database contexthash- the SHA-512 content hashout- the output stream to write to- Throws:
Exception- if streaming fails- See Also:
-
supportsRangeDelivery
Description copied from interface:I_CmsStorageDeliveryReturns if range delivery is supported.- Specified by:
supportsRangeDeliveryin interfaceI_CmsStorageDelivery- Returns:
trueif byte range delivery is supported- See Also:
-
validateAvailable
Description copied from interface:I_CmsStorageValidates that the storage backend is available for read and write operations.This method is called during startup for configured storage backends. Implementations should perform a lightweight roundtrip which verifies the required prerequisites for storing content.
- Specified by:
validateAvailablein interfaceI_CmsStorage- Parameters:
dbc- the database context- Throws:
Exception- if the storage backend is not available- See Also:
-
visitContentHashes
public void visitContentHashes(CmsDbContext dbc, I_CmsEnumerableStorage.I_CmsContentHashVisitor visitor) throws Exception Description copied from interface:I_CmsEnumerableStorageVisits all content hashes stored by this backend.- Specified by:
visitContentHashesin interfaceI_CmsEnumerableStorage- Parameters:
dbc- the database contextvisitor- the content hash visitor- Throws:
Exception- if enumeration fails- See Also:
-