egg 读取上传文件的内容

Created on 10 Apr 2018  ·  5Comments  ·  Source: eggjs/egg

我上传了一个data.json文件, 然后想要把里面的内容读取出来

Most helpful comment

明显你这个不是正规用法,会有坑

All 5 comments

已经解决,内容藏得有点深

        const stream = await ctx.getFileStream(); // 读取流
使用
stream.on('data',function(chunk) {
// 读取内容
})

我是直接用stream._readableState.buffer.head.data.toString()也能取到值,不过你的比较好

明显你这个不是正规用法,会有坑

需要学习下 stream

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fengmk2 picture fengmk2  ·  51Comments

popomore picture popomore  ·  59Comments

andylei18 picture andylei18  ·  35Comments

occultskyrong picture occultskyrong  ·  35Comments

popomore picture popomore  ·  38Comments