I recently ran into the JavaScript Blob object, I used it to initialize a web worker where the code was contained within a script tag in the document.
Based on the MDN documentation:
A Blob object represents a file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format.
It sounds like it acts as a sack to put a collection of things into that all share a MIME type. Am I wrong in this opinion, is this opinion incomplete?
Why is the object needed/useful?
The blob object is used for representing a blob object which is immutable and is used for representing raw data. The blob has a size and mime type property just like a file has. File is a derivation of blob and blob can be used in places where the file is used.
A blob is a data type that can store binary data. This is different than most other data types used in databases, such as integers, floating point numbers, characters, and strings, which store letters and numbers. Since blobs can store binary data, they can be used to store images or other multimedia files.
Blob URLs contain pseudo protocols that can create a temporary URL to audio and video files. This type of URL essentially acts as a fake source for the media on the website, so you can't download it directly. Instead, you have to use third-party conversion tools.
Binary large object (BLOB) is a generic term used to describe the handling and storage of long strings of data by database management systems.
Blob
s aren't terribly useful on their own. What's useful about them is that they work with many calls which are meant to process File
s. The most important of these is URL.createObjectURL()
, which can be used to create a URL you can then use in the href
or src
attributes of HTML tags, @import
statements and url()
values in CSS, etc.
Basically, Blob
gives JavaScript something like temporary files, and URL.createObjectURL()
lets you treat those blobs as though they were files on a web server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With