egg返回base64图片

Others 2020-09-04 02:55:24 2020-09-04 02:55:24 1642 次浏览
 //去掉base64的头部分, 转成buffer
    const base64 = 'iVBORw0KGgo...==';
    const imageBufferData = Buffer.from(base64, 'base64');
    ctx.body = imageBufferData;
    ctx.response.type = 'image/png';