How To Display BLOB Content In JavaScript

- 1 answer

how can i display the content on a BLOB? I tried this code

openBlob = fileBuffer => {
var BLob = require('blob');
const file = new BLob([fileBuffer, blob]); // You could also add the MIME type here as { 
type: "application/pdf" }
const fileURL = URL.createObjectURL(file);
console.log("fileURL" + fileURL), "_blank_");

render() {
const archivioItems =, i) => {
  return (
    <tr key={archivio.hash_referto}>
        <Tab icon={<AssignmentIcon />}              
           onClick={() => this.openBlob(archivio.uri)}></Tab>

but it says that "Module not found: Error: Can't resolve 'blob'" and when i click on the Assignment Icon it says that BLob is not defined. How can i fix it?



I think you are missing the 'blob' packet reference and your require call does not resolve it. Install the packet with npm install blob.

You also have a typo on the new 'BLob', so make it so

const file = new Blob([fileBuffer, blob]); 

EDIT: Do also add the MIME type that you have left out in comments for the new Blob call!

{ type: "application/pdf" }