问题
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 Blob
s.
One example advantage to using Blob
s 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