← Back to IO domain
IO.read
Read a chunk of the stream
Domain: IO
stable
Parameters
| Name | Type | Description |
handle | StreamHandle | Handle of the stream to read. |
offset (optional) | integer | Seek 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) | integer | Maximum number of bytes to read (left upon the agent discretion if not specified). |
Returns
| Name | Type | Description |
base64Encoded | boolean | Set if the data is base64-encoded |
data | string | Data that were read. |
eof | boolean | Set 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}