Interface CmsMediaStorageSpec


public interface CmsMediaStorageSpec
Media storage configuration for CMS platforms.

Defines S3 offloading capabilities and plugin configurations for CMS media uploads. When enabled, media files are stored in S3 instead of the local filesystem, enabling:

  • Horizontal scaling (multiple container instances)
  • CDN integration via CloudFront
  • Reduced EFS/EBS storage costs
  • Better performance through S3's distributed storage

Usage Example:

if (spec instanceof CmsMediaStorageSpec mediaSpec) {
    if (mediaSpec.isS3OffloadingEnabled()) {
        String bucket = mediaSpec.getMediaBucketName();
        Map<String, String> env = mediaSpec.getS3PluginEnvironment();
    }
}

4.0 migration intent

This is a CMS compatibility/binding contract, not a CMS-only infrastructure model. During the 4.0 migration, its shared storage and delivery concerns are adapted to named typed requirements such as storage.media and an optional delivery/CDN policy. Provider selection, bucket naming, IAM, encryption, public-access blocking, retention, versioning, target support, entitlement restrictions, and compliance evidence are resolved by the platform, not by this interface or a CMS plugin.

Methods that describe how a particular CMS configures its S3/offload extension remain application-owned binding behavior. New application plugins should request reusable object storage and delivery capabilities directly; existing implementations remain supported through the 4.0 compatibility adapter until their regression coverage proves equivalent behavior.

Since:
3.1.0
See Also:
  • Method Details

    • isS3OffloadingEnabled

      boolean isS3OffloadingEnabled()
      Returns whether S3 media offloading is enabled.

      When enabled, media uploads are stored in S3 instead of local filesystem. This requires proper IAM permissions and plugin configuration.

      Returns:
      true if S3 offloading is enabled
    • getMediaBucketName

      String getMediaBucketName()
      Returns the S3 bucket name for media storage.

      This bucket should be provisioned with appropriate policies:

      • Block public access enabled
      • Versioning enabled for recovery
      • Lifecycle rules for old version cleanup
      • CORS configuration for browser uploads
      Returns:
      S3 bucket name for media storage
    • getMediaKeyPrefix

      default String getMediaKeyPrefix()
      Returns the S3 key prefix for media files.

      Organizes media files within the bucket. Common patterns:

      • "uploads/" - WordPress standard
      • "media/" - Generic pattern
      • "pub/media/" - Magento pattern
      Returns:
      S3 key prefix (default: "uploads/")
    • getMediaBucketRegion

      String getMediaBucketRegion()
      Returns the S3 region for the media bucket.

      Should match the deployment region for optimal performance.

      Returns:
      AWS region (e.g., "us-east-1")
    • getS3PluginEnvironment

      Map<String,String> getS3PluginEnvironment()
      Returns environment variables for S3 plugin configuration.

      CMS-specific environment variables for configuring S3 media plugins:

      WordPress (WP Offload Media):

      • AS3CF_SETTINGS - JSON configuration
      • WP_OFFLOAD_MEDIA_BUCKET - Bucket name
      • WP_OFFLOAD_MEDIA_REGION - AWS region

      Magento:

      • AWS_S3_BUCKET - Bucket name
      • AWS_S3_REGION - AWS region
      • AWS_S3_PREFIX - Key prefix

      Drupal (S3FS):

      • S3FS_BUCKET - Bucket name
      • S3FS_REGION - AWS region
      Returns:
      map of environment variable key-value pairs
    • deleteLocalAfterUpload

      default boolean deleteLocalAfterUpload()
      Returns whether to delete local files after S3 upload.

      When true, files are removed from local storage after successful S3 upload. This saves local storage but requires reliable S3 connectivity.

      Recommended settings:

      • Fargate: true (ephemeral storage)
      • EC2 with EFS: true (saves EFS costs)
      • EC2 with EBS: false (keep local backup)
      Returns:
      true to delete local files after upload (default: false)
    • getCdnMediaUrl

      String getCdnMediaUrl()
      Returns the CloudFront URL for media if CDN is enabled.

      When a CloudFront distribution is configured for the media bucket, this URL is used for serving media files to visitors.

      Returns:
      CloudFront URL (e.g., "https://d1234.cloudfront.net") or null
    • rewriteUrlsForCdn

      default boolean rewriteUrlsForCdn()
      Returns whether to rewrite URLs to use CDN.

      When enabled, media URLs in content are rewritten to use the CDN domain instead of S3 or local URLs.

      Returns:
      true to rewrite URLs (default: true if CDN URL is set)
    • allowedMimeTypes

      default List<String> allowedMimeTypes()
      Returns the allowed MIME types for media uploads.

      Used for S3 bucket policy and upload validation. Empty list means all types are allowed.

      Returns:
      list of allowed MIME types, or empty for all
    • maxUploadSizeMb

      default int maxUploadSizeMb()
      Returns the maximum file size for uploads in megabytes.

      Used for S3 bucket policy and CMS configuration.

      Returns:
      max file size in MB (default: 128MB)
    • enableTransferAcceleration

      default boolean enableTransferAcceleration()
      Returns whether to enable S3 Transfer Acceleration.

      Transfer Acceleration uses CloudFront edge locations for faster uploads, useful for global teams.

      Returns:
      true to enable Transfer Acceleration (default: false)
    • storageClass

      default String storageClass()
      Returns the storage class for media files.

      S3 storage classes:

      • STANDARD - Frequently accessed
      • INTELLIGENT_TIERING - Auto-tiering
      • STANDARD_IA - Infrequent access
      Returns:
      S3 storage class (default: "STANDARD")