http://onionworks.net/2006/data/application

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 onion.net 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 onion.net, then no ReferenceIdentifier is returned.

Files for example, which were uploaded via a form of the GenericForms module, can be stored in the onion.net 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="http://onionworks.net/2004/renderengine/web/genericforms" xmlns:app="http://onionworks.net/2006/data/application" xmlns:onion="http://onionworks.net/2004/data" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 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:http://test.de/userprofile">
<file>
<xsl:value-of select="$tempFileRef" />
</file>
</node>
</xsl:variable>
<xsl:value-of select="c.choose(app:updateObject($objectId, $data), 'Successfull', 'Error')" />
</xsl:template>
</xsl:stylesheet>

See also