Sometimes, we want to get a file or blob from an object URL with JavaScript.
In this article, we’ll look at how to get a file or blob from an object URL with JavaScript.
How to get a file or blob from an object URL with JavaScript?
To get a file or blob from an object URL with JavaScript, we use fetch
.
For instance, we write
const r = await fetch(url);
const blob = await r.blob();
to call fetch
with the object url
.
Then we get the blob from the response with r.blob
.
Conclusion
To get a file or blob from an object URL with JavaScript, we use fetch
.