为什么使用blob? [英] Why are blobs used?

查看:165
本文介绍了为什么使用blob?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Blob是Linairy Large OBjects,但为什么会使用它们,特别是在JavaScript的上下文中?



如果你搜索interwebz,你会得到很多blob的定义,但不是为什么使用它们。



所以我的问题是:




  • 为什么? (在哪种情况下,用例?)


    • 特别是关于Cordova中的filestorage(所以通过JavaScript)


  • 使用blob时增值是什么。



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



编辑:可以看到Cordova中blob使用的示例这里



提前致谢!

解决方案


使用blob时的附加值是什么。



示例:将数据存储到文件系统(通过JavaScript),
教程首先在存储之前将String转换为blob。但是
为什么?您可以将String值写入文件,它不需要
作为blob。


A Blob 可以存储字符串数字数组 ArrayBuffer 布尔值单个或多个文件对象,继承自 Blob ,或多个 Blob s。



使用 Blob 而不是 String 的一个示例优势是存储单个或多个文件单个 Blob 中的对象,而不是可能冗长的数据URI 数据URI 中的c $ c>或数据URI


Blobs are Linairy Large OBjects, but why are they used, especially in the context of JavaScript?

If you search the interwebz, you get alot of definitions of blobs, but not why they are used.

So my questions are:

  • Why? (in which context, use cases?)
    • Especially regarding filestorage in Cordova (so by means of JavaScript)
  • 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.

Edit: An example of blob usage in Cordova can be seen here

Thanks in advance!

解决方案

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.

A Blob can store String, Number, Array, ArrayBuffer, Boolean a single or multiple File objects, which inherits from Blob, or multiple Blobs.

One example advantage to using Blobs instead of String would be storing single or multiple File objects within a single Blob instead of a possibly lengthy data URI, or data URI within a data URI.

这篇关于为什么使用blob?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆