Skip to main content

Outline

At a glance
  • Hybrid Architecture: Managing media as database metadata linked to cloud-native binary blobs.
  • Binary Lifecycle: Utilizing IBlobFactory to create, stream, and persist file data programmatically.
  • Governance: Aligning asset folder hierarchies with the page tree to maintain editor ergonomics.
  • Security & Deletion: Mastering soft vs. permanent deletes and ensuring the cleanup of orphaned blobs.

In an enterprise Content Management System, media is more than just a background image; it is a critical asset that carries legal, brand, and performance implications. In Optimizely CMS 13 (PaaS), the management of binary data—images, videos, and documents—requires a distinct programmatic approach compared to standard text-based content. While a PageData object stores its information in SQL rows, a MediaData object represents a hybrid entity: metadata stored in the database and binary bits stored in the cloud-native blob storage.

Working with Shared Content (Blocks and Folders) and Media safely is a core technical requirement for the PaaS CMS 13 Developer Certification. Programmatic operations in this area must account for file stream management, unique blob identifier generation, and the enforcement of organizational folder standards. This activity explores the architecture of the IBlobFactory, the lifecycle of a programmatic asset upload, and the governance patterns required to maintain a clean, performant asset library in a PaaS environment.

1. Defining the Media Content Model

Before you can upload a single byte, you must define the schema for your media. In Optimizely, media items are strongly-typed .NET classes. Using specifically designed base classes ensures the CMS UI provides the correct tools for editors.

The Media Hierarchy:

  • MediaData: The base class for generic file types like PDFs or Word documents.
  • ImageData: Inherits from MediaData. Enables automatic thumbnail generation and built-in cropping tools.
  • VideoData: Specialized for video assets, supporting frame extraction and player integration.
[ContentType(GUID = "EE23-...", DisplayName = "Standard Image")] [MediaDescriptor(ExtensionString = "jpg,jpeg,png,webp")] public class ImageFile : ImageData { }

2. The Binary Lifecycle: IBlobFactory and BinaryData

Actual binary content is never stored directly in the Optimizely database. Instead, the BinaryData property holds a URI pointing to a blob in PaaS storage. Programmatic uploads must manage this link explicitly.

Programmatic Upload Workflow

  1. Instantiate the content shell using IContentRepository.GetDefault<T>().
  2. Allocate space in the blob container via IBlobFactory.CreateBlob().
  3. Write the file bytes to the blob using a Stream.
  4. Link the resulting blob URI to the content item and save.
var myImage = _repository.GetDefault<ImageFile>(folderRef); myImage.Name = "Hero.jpg"; var blob = _blobFactory.CreateBlob(myImage.BinaryDataContainer, ".jpg"); using (var stream = file.OpenReadStream()) { blob.Write(stream); } myImage.BinaryData = blob; _repository.Save(myImage, SaveAction.Publish, AccessLevel.NoAccess);

3. Organizing Assets: Folder and Block Governance

A dangerous anti-pattern is the "Flat Asset Library," which overwhelms the editor UI. Developers should enforce organizational standards by mirroring the page tree in the asset library. Since folders are shared between Media and Blocks, creating a unified hierarchy (e.g. "Products > Clothing") allows editors to find related images and promotional blocks in one place.

4. Deletion and Orphaned Data Management

Cleaning up old data is essential for maintaining database health. Optimizely supports Soft Deletes (moving to Trash) and Permanent Deletes. When a media item is permanently removed, the platform automatically cleans up the binary blob in the background. However, administrators should still run the "Remove Orphaned Blobs" scheduled job regularly to catch items that lost their metadata references.

Conclusion

Working with media and shared content in Optimizely CMS 13 requires a deep understanding of the decoupled relationship between metadata and binary storage. By strictly utilizing the IBlobFactory for secure file streaming, enforcing organizational folder hierarchies through programmatic utilities, and maintaining a disciplined approach to versioning and deletion, developers can build a high-performance asset ecosystem that remains governed and auditable. Mastering these patterns is a vital component of the PaaS CMS 13 Developer Certification, as it bridges the gap between simple content modeling and the robust technical management required for large-scale enterprise media libraries.