Save Scenes to a Blob
In this example, we will show you how to save scenes as a Blob
with the CreativeEditor SDK.
Explore a full code sample on Stackblitz or view the code on Github.
The CreativeEngine allows you to save scenes in a binary format to share them between editors or store them for later editing.
This is done by converting the contents of a scene to a string, which can then be stored or transferred.
For sending these to a remote location, we wrap them in a Blob
and treat it as a file object.
Warning#
A scene file does not include any fonts or images. Only the source URIs of assets, the general layout, and element properties are stored. When loading scenes in a new environment, ensure previously used asset URIs are available.To get hold of the scene contents as string, you need to use engine.scene.saveToString()
.
This is an asynchronous method returning a Promise
.
After waiting for the Promise
to resolve, we receive a plain string holding the entire scene currently loaded in the editor.
This includes all pages and any hidden elements but none of the actual asset data.
The returned string consists solely of ASCII characters and can safely be used further or written to a database.
In this case, we need a Blob
object, so we proceed to wrap the received string into a Blob
, a file-like object of immutable, raw data.
That object can then be treated as a form file parameter and sent to a remote location.