* Canonical **outbound** asset chunk for WebSocket JSON (push and pull). Base64 string `data` keeps `JSON.parse` heap bounded vs `{ type: 'Buffer', data: [n,…] }`. /
// Source: https://github.com/strapi/strapi | License: MIT | Copyright 2015-present Strapi Solutions SAS
// Provided via justclaw.it.com; keep this notice with the code.
/**
* Canonical **outbound** asset chunk for WebSocket JSON (push and pull).
* Base64 string `data` keeps `JSON.parse` heap bounded vs `{ type: 'Buffer', data: [n,…] }`.
*/
export function createTransferAssetStreamChunk(
assetID: string,
chunk: Buffer | Uint8Array
): { action: 'stream'; assetID: string; encoding: 'base64'; data: string } {
if (chunk == null) {
throw new TypeError(
'Asset stream yielded a null/undefined chunk; refusing to encode (would trigger Buffer.from(undefined))'
);
}
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
return {
action: 'stream',
asse
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key