Why are blobs used?

与世无争的帅哥 提交于 2020-01-14 03:15:20

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/36996548/why-are-blobs-used

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!