包.json
{
"type": "module",
"dependencies": {
"@types/node": "^18.6.5",
"typescript": "^4.7.4"
}
}
Run Code Online (Sandbox Code Playgroud)
tsconfig.json
{
"compilerOptions": {
"target": "ES2021",
"module": "ESNext",
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
Run Code Online (Sandbox Code Playgroud)
使用节点 v18.7.0,我尝试将从本机 fetch API 返回的网络流转换为节点流。我使用“node:stream”模块中的 Readable.fromWeb 方法。Typescript 返回类型检查错误,但代码使用 @ts-ignore 注释按预期工作。
类型错误
Argument of type 'ReadableStream<Uint8Array>' is not assignable to parameter of type 'ReadableStream<any>'.
Type 'ReadableStream<Uint8Array>' is missing the following properties from type 'ReadableStream<any>': values, [Symbol.asyncIterator]
const nodeStream = Readable.fromWeb(fetchRequest.body)
Run Code Online (Sandbox Code Playgroud)
源代码
Argument of type 'ReadableStream<Uint8Array>' is not assignable to parameter of …Run Code Online (Sandbox Code Playgroud) 我有一个可能很大的文件(100+ Mb)的url,如何使用访存将其保存在本地目录中?
我环顾四周,但是关于如何执行此操作似乎没有很多资源/教程。
谢谢!
我想让用户从我的 AWS S3 存储桶下载视频。视频格式为MP4:
app.get("/download_video", function(req,res) {
filename = "s3.xxx.amazon.com/bucketname/folder/video_example.mp4";
// im stuck on what i can do here
});
Run Code Online (Sandbox Code Playgroud)
有很多关于如何使用nodejs在线下载图像和文本文件的示例,但我在视频上找不到任何内容。