fetch('downfile/9043.wav')
.then(function(data){
consume(data);
return data;
})
.then((data) =>{
console.data
})
.catch((e) => {console.log("something went wrong: " + e)});
function consume(reader) {
var getReader = reader.body.getReader();
var total = 0;
return new Promise((resolve, reject) => {
function pump() {
getReader.read().then(({done, value}) => {
if (done) {
resolve();
return ;
}
total += value.byteLength;
// console.log(下载字节 ${value.byteLength} bytes (${total} 总下载字节)
);
pump();
}).catch(reject)
}
pump();
});
}
只读流被锁定,不能转换成arraybuffer 或其他格式。导致后面无法转化成Uint8Array 并创建文件流下载到本地
使用.close 方法也不能解锁, 求解
后面怎么解决的,这个只能获取流吗 上传文件怎么监听他上传打哪一步了