pipeStream.js
Methods
(path)#
createStreamCreates readStream from a file. 'highWaterMark' determines the size of data (and payment) chunks. For audio streaming it's recommended to keep it small (2**13), since big chunks can cause errors in payment calculation. On the other hand for video streaming bigger chunks (e.g. 2**16), can speed up the stream loading.
Parameters:
Name | Type | Description |
---|---|---|
path | string | to the file |
- Source:
(meta, stream, userId)#
pipeMediaIntoStreamListen to file stream *readable* event for piping the data, and close the stream when no more data to be read.
Parameters:
Name | Type | Description |
---|---|---|
meta | object | streamingFileMeta, including *pricePerByte* property |
stream | object | node.js Readable stream |
userId | string |
- Source:
(async) pipeStream(meta, stream, userId)#
Calculates cost of data stream chunk and pipes the stream if is able to pay that cost. Otherwise waits for new payments and retries in 400ms.
Parameters:
Name | Type | Description |
---|---|---|
meta | object | streamingFileMeta, including *pricePerByte* property |
stream | object | node.js Readable stream |
userId | string |
- Source:
(ctx, meta)#
prepareStreamCtxSet request headers and longer than default timeout for wainting payments.
Parameters:
Name | Type | Description |
---|---|---|
ctx | object | node.js request context |
meta | object | streamingFileMeta, including *fileSize* and *mime* properties |
- Source: