Image

The Image class can be used to create an Image, which can be used in the Flow Editor. An image must be registered, and the contents will be retrieved when needed.

Methods

getStream

(async) getStream(): Promise.<NodeJS.ReadableStream>

Returns a stream containing the image data.

Returns

A nodejs stream containing the image data. The readable stream contains metadata properties (Image.ImageStreamMetadata)

Promise.<NodeJS.ReadableStream>

pipe

(async) pipe(stream): Promise.<Image.ImageStreamMetadata>

Pipe the image into the target stream and returns metadata.

Parameters

Name Type Description
stream
NodeJS.WritableStream

Returns

Stream metadata

setPath

setPath(path)

Set the image's path

Parameters

Name Type Description
path
string

Relative path to your image, e.g. /userdata/kitten.jpg

setStream

setStream(source)

Set the image's data.

Parameters

Name Type Description
source
function

This function will be called with the parameter (stream) when someone pipes this image. Pipe the image content to the stream. This is mostly useful for external image sources.

setUrl

setUrl(url)

Set the image's URL. This URL must be accessible from any network.

Parameters

Name Type Description
url
string

Absolute url, https://

unregister

(async) unregister()

Unregister the image. This is a shorthand method for ManagerImages#unregisterImage.

update

(async) update(): Promise.<any>

Notify that the image's contents have changed

Returns

Promise.<any>

Type Definitions

ImageStreamMetadata

ImageStreamMetadata

Properties

Name Type Description
filename
string

A filename for this image

contentType
string

The mime type of this image

contentLength
number <optional>

The size in bytes, if available