Skip to content

Extension points

Both enums at the heart of Media Bridge are extensible. This page describes the contracts and what is and isn't supported today.

The FRW IMediaEntity contract

An adapter tells Media Bridge how to work with the pictures of one table.

Procedure Purpose
GetFolderName(): Text Sub-folder in external storage, for example Items.
GetBucketKey(EntityRecordRef): Text Short bucket folder, usually the first two characters of the record number.
GetDescription(EntityRecordRef): Text Readable name, used as caption and in the migration log.
GetExtFilePath / GetExtFileMimeType(EntityRecordRef): Text Read the external file reference fields.
SetExtFileReference(var EntityRecordRef; FilePath; ModifiedAt; MimeType) Write and persist the reference fields.
ClearExtFileReference(var EntityRecordRef) Clear and persist the reference fields.
HasMedia(EntityRecordRef): Boolean Whether the Tenant Media field holds a picture.
ImportMedia(var EntityRecordRef; PictureInStream; MimeType) Import into the Tenant Media field. Writes to the database: never call it inside a [TryFunction].
ClearMedia(var EntityRecordRef) Clear the Tenant Media field on the RecordRef only; the caller persists it.
TryGetMediaStream(EntityRecordRef; var TempBlob): Boolean Read the Tenant Media picture.
OpenRecordSet(var EntityRecordRef) Open the table with the load fields the migration needs.
GetTableNo(): Integer The table the adapter serves.
GetFileScenario(): Enum "File Scenario" The File Scenario whose account stores the pictures.
SupportsMediaSourceCompany(): Boolean Whether the entity reads from the media source company in consumer mode.

Because the migration loops over Enum "FRW Media Entity".Ordinals(), a new entity is picked up by the migration wizard, the migration log and the connection test without any change to them.

Adding an entity inside Media Bridge

Within the Media Bridge app, a new entity (Contact, Resource and Customer are candidates) needs:

  1. An enum value on FRW Media Entity with its adapter codeunit.
  2. A table extension with the three FRW Ext. File ... fields.
  3. A factbox page hosting the FRW Picture Drop add-in, and a page extension that replaces the standard picture factbox.
  4. An OnAfterDeleteEvent subscriber that calls CleanupDeletedRecordMedia on FRW Media Storage Mgt.
  5. Optionally its own File Scenario value, and its own clear codeunit and query.

Adding an entity from another extension

  • The enum and the interface are public, so another app can add an entity value and adapter.
  • CleanupDeletedRecordMedia is internal. An external entity must take care of deleting its external file when a record is deleted itself.
  • The Clear utilities only cover items, item variants and employees.

The FRW IMediaStorageProvider contract

Procedure Purpose
UploadPicture(MediaEntity; var EntityRecordRef; PictureInStream; MimeType; var FilePath; var ModifiedAt) Write the bytes. Don't modify the record: return the path and timestamp.
DeletePicture(MediaEntity; var EntityRecordRef) Delete the bytes. Don't clear the record's reference.
TryGetPictureStream(MediaEntity; EntityRecordRef; var TempBlob): Boolean Read the bytes. Raise inside your own try, so the caller's GetLastErrorText() explains a failure.
TestConnection(): Boolean Test access to the storage.

Third-party storage providers: current limits

The enum accepts new values, but several parts of Media Bridge still make a two-way choice between Tenant Media and External File Storage: the migration's "has a picture in this source" check, the read fallback for mixed states, how an upload is recorded on the record, and the wizard's counts per storage. A third provider is treated like Tenant Media in those places. Contact The Framework before you build a provider, so the required generalisation can be planned.

Test seams

  • FRW Ext. Storage Provider resolves its file operations through interface "FRW IExternalFileOps" (create, get, delete, test connection). The integration event OnResolveFileOps lets a test substitute a fake, so tests run without a real storage account.
  • The add-ins are driven through FRW IItemCarousel and FRW IPictureDropControl, so drop handling is tested with mocks.