Koa: How to send binary data

Created on 6 Jul 2017  路  2Comments  路  Source: koajs/koa

Hello!

I'm building an app using awesome Koa2.
Could you please tell me how can I send binary data (i. e. ArrayBuffer)?

Thanks!

Most helpful comment

Buffer Data

const buf = Buffer.alloc(1024);
ctx.body = buf;

Stream object

const stream = fs.createReadStream(__filename);
ctx.body = stream;

All 2 comments

Buffer Data

const buf = Buffer.alloc(1024);
ctx.body = buf;

Stream object

const stream = fs.createReadStream(__filename);
ctx.body = stream;

Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wlingke picture wlingke  路  3Comments

tvq picture tvq  路  4Comments

xinshouke picture xinshouke  路  4Comments

ilkkao picture ilkkao  路  4Comments

ke1Del picture ke1Del  路  3Comments