版本:node10 、axios0.19.0
问题:
[ol]
[/ol]
代码及打印:(删除相关敏感信息)
const writer = fsx.createWriteStream(file)
axios
.get(url, {
responseType: 'stream',
...options
})
.then((res) => {
res.data.pipe(writer)
writer.on('error', (err) => {
utils.log(`download error`, err)
reject(err)
})
writer.on('finish', (res) => {
utils.log(`download finish`, res)
resolve(res)
})
writer.on('close', (err) => {
utils.log(`download close`, err)
})
res.data.on('error', (err) => {
utils.log(`download error2`, err)
})
res.data.on('end', (err) => {
utils.log(`download end`, err)
})
res.data.on('aborted', (err) => {
utils.log(`download aborted`, err)
})
res.data.on('close', () => {
if (res.request.aborted) {
utils.log('download aborted')
} else {
utils.log('download completed')
}
})
})
[info] download aborted undefined
[info] download end undefined
[info] download completed
[info] download finish undefined
[info] download close undefined