

Blob URLs (ref W3C, official name) or Object-URLs (ref. MDN and method name) are used with a Blob or a File object.
src=“blob:https://crap.crap” I opened the blob url that was in src of video it gave a error and i can’t open but was working with the src tag how it is possible?
Blob URLs can only be generated internally by the browser. URL.createObjectURL()
will create a special reference to the Blob or File object which later can be released using URL.revokeObjectURL()
. These URLs can only be used locally in the single instance of the browser and in the same session (ie. the life of the page/document).
What is blob url?
Why it is used?
Blob URL/Object URL is a pseudo protocol to allow Blob and File objects to be used as URL source for things like images, download links for binary data and so forth.
For example, you can not hand an Image object raw byte-data as it would not know what to do with it. It requires for example images (which are binary data) to be loaded via URLs. This applies to anything that require an URL as source. Instead of uploading the binary data, then serve it back via an URL it is better to use an extra local step to be able to access the data directly without going via a server.
It is also a better alternative to Data-URI which are strings encoded as Base-64. The problem with Data-URI is that each char takes two bytes in JavaScript. On top of that a 33% is added due to the Base-64 encoding. Blobs are pure binary byte-arrays which does not have any significant overhead as Data-URI does, which makes them faster and smaller to handle.
Can i make my own blob url on a server?
No, Blob URLs/Object URLs can only be made internally in the browser. You can make Blobs and get File object via the File Reader API, although BLOB just means Binary Large OBject and is stored as byte-arrays. A client can request the data to be sent as either ArrayBuffer or as a Blob. The server should send the data as pure binary data. Databases often uses Blob to describe binary objects as well, and in essence we are talking basically about byte-arrays.
if you have then Additional detail
You need to encapsulate the binary data as a BLOB object, then use URL.createObjectURL()
to generate a local URL for it:
var blob = new Blob([arrayBufferWithPNG], {type: "image/png"}),
url = URL.createObjectURL(blob),
img = new Image();
img.onload = function() {
URL.revokeObjectURL(this.src); // clean-up memory
document.body.appendChild(this); // add image to DOM
}
img.src = url; // can now "stream" the bytes
Note that URL
may be prefixed in webkit-browsers, so use:
var url = (URL || webkitURL).createObjectURL(...);
Source: StackOverflow
The Blob
object represents a blob, which is a file-like object of immutable, raw data; they can be read as text or binary data, or converted into a ReadableStream
so its methods can be used for processing the data.
Blobs can represent data that isn’t necessarily in a JavaScript-native format. The File
interface is based on Blob
, inheriting blob functionality and expanding it to support files on the user’s system.
To construct a Blob
from other non-blob objects and data, use the Blob()
constructor. To create a blob that contains a subset of another blob’s data, use the slice()
method. To obtain a Blob
object for a file on the user’s file system, see the File
documentation.
The APIs accepting Blob
objects are also listed in the File
documentation.
Returns a newly created Blob
object which contains a concatenation of all of the data in the array passed into the constructor.
Blob.prototype.size
Read only
The size, in bytes, of the data contained in the Blob
object.
Blob.prototype.type
Read only
A string indicating the MIME type of the data contained in the Blob
. If the type is unknown, this string is empty.
Returns a promise that resolves with an ArrayBuffer
containing the entire contents of the Blob
as binary data.
Returns a new Blob
object containing the data in the specified range of bytes of the blob on which it’s called.
Returns a ReadableStream
that can be used to read the contents of the Blob
.
Returns a promise that resolves with a USVString
containing the entire contents of the Blob
interpreted as UTF-8 text.
The Blob()
constructor can create blobs from other objects. For example, to construct a blob from a JSON string:
const obj = {hello: 'world'};
const blob = new Blob([JSON.stringify(obj, null, 2)], {type : 'application/json'});
The following code creates a JavaScript typed array and creates a new Blob
containing the typed array’s data. It then calls URL.createObjectURL()
to convert the blob into a URL.
<p>This example creates a typed array containing the ASCII codes
for the space character through the letter Z, then converts it
to an object URL. A link to open that object URL is created.
Click the link to see the decoded object URL.</p>
The main piece of this code for example purposes is the typedArrayToURL()
function, which creates a Blob
from the given typed array and returns an object URL for it. Having converted the data into an object URL, it can be used in a number of ways, including as the value of the <img>
element’s src
attribute (assuming the data contains an image, of course).
function typedArrayToURL(typedArray, mimeType) {
return URL.createObjectURL(new Blob([typedArray.buffer], {type: mimeType}))
}
const bytes = new Uint8Array(59);
for(let i = 0; i < 59; i++) {
bytes[i] = 32 + i;
}
const url = typedArrayToURL(bytes, 'text/plain');
const link = document.createElement('a');
link.href = url;
link.innerText = 'Open the array URL';
document.body.appendChild(link);
Click the link in the example to see the browser decode the object URL.
One way to read content from a Blob
is to use a FileReader
. The following code reads the content of a Blob
as a typed array:
const reader = new FileReader();
reader.addEventListener('loadend', () => {
// reader.result contains the contents of blob as a typed array
});
reader.readAsArrayBuffer(blob);
Another way to read content from a Blob
is to use a Response
. The following code reads the content of a Blob
as text:
const text = await (new Response(blob)).text();
Or by using Blob.prototype.text()
:
const text = await blob.text();
By using other methods of FileReader
, it is possible to read the contents of a Blob as a string or a data URL.
Continue reading: https://developer.mozilla.org/en-US/docs/Web/API/Blob
Happy learning!
I found a way to download the video with blob url
in Vimeo
(reading here i understood how doing it). I write the simple steps here. I’m using Google Chrome:
More Tools
→ Developer Tools
<video preload="" src="blob:https://player.vimeo.com/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"></video>
http://player.vimeo.com/video/XYZ
if you found it you can go straight to the point 7, otherwise follow steps 4, 5, 6.https://skyfire.vimeocdn.com/.../master.json?base64_init=1
inside the page (using the Developer View), you should found it inside a javascript function, like this:(function(e,a){var t={"cdn_url":"https://f.vimeocdn.com","view":1,"request":{"files":{"dash":{"origin":"gcs","url":"https://48skyfiregce-a.akamaihd.net/.../master.json?base64_init=1","cdn":"
https://48skyfiregce-a.akamaihd.net/.../master.json?base64_init=1
end open it with a browser, it will open you a json file like this:{
"clip_id": XYZ,
"base_url": "../",
"video": [
{ ... ... ...
XYZ
like this: https://player.vimeo.com/video/XYZ
blob:https://player.vimeo.com/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
inside the video tag with that last url (the one created in the previous step #6).<video preload="none" src="https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/XX/XXX/X/XXXXXXXX/XXXXXXXXX.mp4?token=abcdefg"></video>
Margaret, you are the best, thank you vey much for your sharing with us that way