gpt4 book ai didi

typescript - 无法将文件转换为 Blob

转载 作者:行者123 更新时间:2023-12-05 01:34:28 26 4
gpt4 key购买 nike

我正在尝试将 File 转换为 Blob,但显然我什至无法将 File 转换为 Blob 的子类。

我试过这样:<Blob>file还有这个:file as Blob .而且错误总是一样的:

Type 'File' cannot be converted to type 'Blob'. Property 'size' is missing in type 'File'.

我做错了什么?

最佳答案

以下显示完全没有错误。

declare const file: File;

const blob = file as Blob;

确保您的 TypeScript 版本是最新的(2.3.2 是撰写本文时的最新版本)

You can see this in action in the TypeScript Playground

关于typescript - 无法将文件转换为 Blob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43767401/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com