← Back to IO domain

IO.read

Read a chunk of the stream

Domain: IO stable

Parameters

NameTypeDescription
handleStreamHandleHandle of the stream to read.
offset (optional)integerSeek to the specified offset before reading (if not specified, proceed with offset following the last read). Some types of streams may only support sequential reads.
size (optional)integerMaximum number of bytes to read (left upon the agent discretion if not specified).

Returns

NameTypeDescription
base64EncodedbooleanSet if the data is base64-encoded
datastringData that were read.
eofbooleanSet if the end-of-file condition occurred while reading.

Example Request

{
  "id": 1,
  "method": "IO.read",
  "params": {
    "handle": "stream-handle"
  }
}

Example Response

{
  "id": 1,
  "result": {
    "base64Encoded": true,
    "data": "base64-encoded-data...",
    "eof": true
  }
}

Usage in Node.js

const result = await send('IO.read', {"handle": "stream-handle"});
console.log(result);
// {"base64Encoded": true, "data": "base64-encoded-data...", "eof": true}