gpt4 book ai didi

javascript - 为什么使用 Blob ?

转载 作者:行者123 更新时间:2023-11-28 06:04:36 25 4
gpt4 key购买 nike

Blob 是线性大型对象,但为什么要使用它们,尤其是在 JavaScript 上下文中?

如果您搜索 interwebz,您会得到很多 blob 的定义,但没有找到使用它们的原因。

所以我的问题是:

  • 为什么? (在什么情况下,用例?)
    • 特别是关于 Cordova 中的文件存储(因此通过 JavaScript)
  • 使用 Blob 时的附加值是什么。

示例:将数据存储到文件系统时(通过 JavaScript),教程首先将字符串转换为 blob,然后再存储。但为什么?您可以将字符串值写入文件,它不需要是 blob。

编辑:Cordova 中 blob 使用的示例可以参见 here

提前致谢!

最佳答案

What is the added value when working with blobs.

Example: When storing data to the filesystem (by means of JavaScript), tutorials first convert the String to a blob before its stored. But Why? You could just write the String value to a file, it doesn't need to be a blob.

一个Blob可存储String , Number , Array , ArrayBuffer , Boolean单个或多个File对象,继承自 Blob ,或多个Blob s。

使用 Blob 的一个示例优势s 而不是 String将存储单个或多个 File单个对象 Blob而不是可能冗长的 data URI ,或data URIdata URI内.

关于javascript - 为什么使用 Blob ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36996548/

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