createBinary (filename : string, mimeType : string) : string

The method “createBinary” writes a binary data object on the basis of a physical file or a link to a binary method in and returns the ReferenceIdentifier as the result. This can then be saved in a data object and to be more precise, in an element of the type “xlink:binaryReference”.

If the binary object cannot be produced in, then no ReferenceIdentifier is returned.

Files for example, which were uploaded via a form of the GenericForms module, can be stored in the Editor with this method. An Avatar picture for a user profile or attachments for Wiki articles would be possible here.

The following example shows how a file from a GenericForms form is produced and saved in a data object.

<xsl:stylesheet xmlns:forms="" xmlns:app="" xmlns:onion="" xmlns:xsl="" version="1.0">
<xsl:template match="/">
<xsl:variable name="tempFileRef" select="app:createBinary($forms:postData/form/file/@physicalFilename, $forms:postData/form/file/@mimetype)" />
<xsl:variable name="objectId">onion://data/objects/42</xsl:variable>
<xsl:variable name="data">
<node onion:schema="Onion:">
<xsl:value-of select="$tempFileRef" />
<xsl:value-of select="c.choose(app:updateObject($objectId, $data), 'Successfull', 'Error')" />

See also