fetch 的getReader 方法不能解锁?

        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();
});
}



clipboard.png
只读流被锁定,不能转换成arraybuffer 或其他格式。导致后面无法转化成Uint8Array 并创建文件流下载到本地
使用.close 方法也不能解锁, 求解

阅读 3.1k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题