Skip to content

Public API

Call codeunit 72539679 "FRW Media Storage Mgt" from your extension to work with pictures. It respects the active storage source and the media source company, so your code works the same way as the Media Bridge pages.

Generic procedures

These work for every media entity. Pass the entity and a RecordRef on the record.

Procedure Description
UploadPicture(Entity; var EntityRecordRef; PictureInStream; MimeType) Stores a picture through the active provider and records the result on the record. Raises an error in a consumer company (for entities that follow the media source company).
DeletePicture(Entity; var EntityRecordRef) Deletes the picture from the active provider, and from the other built-in storage when a copy was left there.
TryGetPictureStream(Entity; EntityRecordRef; var TempBlob): Boolean Reads the picture. In a consumer company, reads from the media source company.
TryGetPictureStreamFrom(Entity; EntityRecordRef; StorageSource; var TempBlob): Boolean Reads the picture from a given storage source, with fallback to the other built-in storage for records that were not migrated yet.
TryGetPicture(Entity; EntityRecordRef; var TempBlob; var MimeType): Boolean Like TryGetPictureStream, and also returns the MIME type, detected from the file contents.
HasPicture(Entity; EntityRecordRef): Boolean Whether the record has a picture in either storage. Reads only the reference fields, not the file.

Item and item variant wrappers

Typed shortcuts for items and variants, so you don't need a RecordRef:

Procedure
UploadItemPicture(var Item; PictureInStream; MimeType)
UploadItemVariantPicture(var ItemVariant; PictureInStream; MimeType)
DeleteItemPicture(var Item)
DeleteItemVariantPicture(var ItemVariant)
TryGetItemPictureStream(Item; var TempBlob): Boolean
TryGetItemVariantPictureStream(ItemVariant; var TempBlob): Boolean
TryGetItemPictureStreamFrom(Item; StorageSource; var TempBlob): Boolean
TryGetItemVariantPictureStreamFrom(ItemVariant; StorageSource; var TempBlob): Boolean
GetItemPictureMimeType(Item): Text
GetItemVariantPictureMimeType(ItemVariant): Text

Storage and setup

Procedure Description
GetActiveSource(): Enum "FRW Media Storage Source" The storage source of this company.
GetEffectiveSource([Entity]): Enum "FRW Media Storage Source" The storage source that really serves the pictures: the source company's in consumer mode.
TestConnection(StorageSource): Boolean Tests the provider's connection.
IsExternalStorageConfigured(): Boolean Whether every Media Bridge file scenario has a file account (directly or through the default account).
CheckExternalStorageConfigured() Raises a clear error when not.
AssignFileAccountToScenarios(var TempFileAccount) Assigns one file account to the file scenario of every media entity.
GetEntityFileScenarios(): List of [Integer] The distinct file scenarios used by the registered entities.
TryResolveEntity(TableNo; var Entity): Boolean Finds the media entity that serves a table.

Example

procedure ShowItemPicture(Item: Record Item)
var
    MediaStorageMgt: Codeunit "FRW Media Storage Mgt";
    TempBlob: Codeunit "Temp Blob";
    EntityRecordRef: RecordRef;
    MimeType: Text;
begin
    EntityRecordRef.GetTable(Item);
    if not MediaStorageMgt.TryGetPicture(Enum::"FRW Media Entity"::Item, EntityRecordRef, TempBlob, MimeType) then
        exit;
    // TempBlob holds the picture bytes; MimeType is e.g. 'image/png'.
end;

Record fields

Each entity table gets three read-only fields:

Field ID Type
FRW Ext. File Path 72539675 Text[500]
FRW Ext. File Modified At 72539676 DateTime
FRW Ext. File MIME Type 72539677 Text[100]

Item and Item Variant also get FRW Product Info URL (72539678, Text[500]). Don't write the three reference fields yourself: use the procedures above.