Media_PeekStream( container { ; streamId } )
Lists either container stream content or dumps a particular stream as text.
Parameters
Parameter | Description |
---|---|
container | A container to peek the stream. |
streamId | Optional. A stream identifier when you want to extract a particular stream instead of the entire container. |
Discusion
The function is useful to examine a container’s content for debugging purposes and can be used in one of the two modes either to list streams or to extract a particular stream.
Listing streams. Media_PeekStream returns a number of streams in the container field along with each stream’s identifier, size, and the first 16 bytes of the data. The stream identifier comprises of 4 alphanumeric letters such as PNGf, JPEG, or SIZE.
Extracting a particular stream requires the second parameter – a stream identifier. Once you do, the function returns the entire stream content as Base64 encoded text.
Examples
To list streams in the container:
MyTable::ContainerList ;
Media_PeekStream( MyTable::container ) ]
Might produce a list of streams like this:
$$$Count: 3 Streams JPEG 8242 bytes [......JFIF.....,] PNGf 70019 bytes [.PNG........IHDR] SIZE 4 bytes [....]
To extract a particular stream data, add the second argument. As you can see from the previous example, there are 3 streams in this container. Two of them are JPEG and PNGf image streams. As per FileMaker’s plug-in documentation, each image container should have a preview in either PNG or JPEG corresponding to the PNGf and JPEG streams above. Suppose we want to extract the JPEG stream:
MyTable::JPEGBase64 ; Media_PeekStream( MyTable::container; "JPEG" ) ]
The result is a Base64 encoded binary data of the JPEG stream.
On Mac, you can obtain the raw data in Terminal.app:
echo 'PASTE_BASE64_HERE' | base64 -d > ~/Desktop/file.jpg
On Windows, you can do the same in PowerShell:
[System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String('PASTE_BASE64_HERE') > %USERPROFILE%\Desktop\file.jpg