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.

Table of Contents

Methods

(async) getStream() → {Promise.<NodeJS.ReadableStream>}

Returns a stream containing the image data.

Since:
  • 2.2.0
Returns:
Type:
Promise.<NodeJS.ReadableStream>

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

(async) pipe(stream) → {Promise.<Image.ImageStreamMetadata>}

Pipe the image into the target stream and returns metadata.

Since:
  • 2.2.0
Parameters:
Name Type Description
stream NodeJS.WritableStream
Returns:
Type:
Promise.<Image.ImageStreamMetadata>

Stream metadata

setPath(path)

Set the image's path

Parameters:
Name Type Description
path String

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

setStream(source)

Set the image's data.

Since:
  • 2.2.0
Library:
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(url)

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

Parameters:
Name Type Description
url String

Absolute url, https://

(async) unregister()

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

(async) update() → {Promise.<any>}

Notify that the image's contents have changed

Returns:
Type:
Promise.<any>

Type Definitions

ImageStreamMetadata

Properties:
Name Type Attributes 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