从 Deno 中的 Fetch Reader 解压
我试图弄清楚为什么我使用这段代码不断收到以下错误,
[uncaught application error]: Error - checksum error
import { Untar } from "https://deno.land/[email protected]/archive/tar.ts";
import { readerFromStreamReader } from "https://deno.land/[email protected]/streams/conversion.ts";
const res = await fetch("https://registry.npmjs.org/react/-/react-17.0.2.tgz", { keepalive: true });
if (res.status === 200) {
const streamReader = res.body!.getReader();
const reader = readerFromStreamReader(streamReader);
const untar = new Untar(reader);
for await (const block of untar) {
// errors with [uncaught application error]: Error - checksum error
}
}
你能从这样的流中解压缩吗?
I'm trying to figure why I keep getting the following erorr with this code
[uncaught application error]: Error - checksum error
import { Untar } from "https://deno.land/[email protected]/archive/tar.ts";
import { readerFromStreamReader } from "https://deno.land/[email protected]/streams/conversion.ts";
const res = await fetch("https://registry.npmjs.org/react/-/react-17.0.2.tgz", { keepalive: true });
if (res.status === 200) {
const streamReader = res.body!.getReader();
const reader = readerFromStreamReader(streamReader);
const untar = new Untar(reader);
for await (const block of untar) {
// errors with [uncaught application error]: Error - checksum error
}
}
Can you Untar from a stream like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在流式传输的响应是使用
gzip
压缩进行压缩的,因此您需要通过 解压转换流先:./so-71365204.ts
The response you are streaming is compressed with
gzip
compression, so you need to pipe the stream data through a decompression transform stream first:./so-71365204.ts