Save blob as File

How to save a blob in you disk as a file

To save a blob as file, you need its blob object first.

You can find it either by adding a debugger point in source code from JavaScript file (from sources tab in Dev Tools) or create your save blob from Network panel.

Now Just run this code snippit to save your file in disk.

// application/pdf is set as example, please set correct MIME type here
let blob = new window.Blob([blobObject], { type: 'application/pdf' });
// Parse blob object to base64 to prevent chrome blocking:
let blobUrl = URL.createObjectURL(blob);

let link = document.createElement("a"); // Or maybe get it from the current document
link.href = blobUrl;
link.download = "file";
link.innerHTML = "Click here to download the file";

// Perform click to initiate download
link.click()

Now you can see a download prompt, just save this file.

Last updated