I am getting a Blob content from webservice callout and requirement is to display the file in browser.
What I have:
- Blob file (fileBlob)
Above blob parameter I get as response and sending same back to javascript method in "callback". I am trying to convert the blob to respective file format and view on browser (I dont want to download unless enduser wants so).
I tried below:
var callback1 = {
onSuccess: function(e){ //e is the blob content I am receiving
alert('Receiving file from SF:---> ' + e);
var file = new File([e], "uploaded_file.pdf", { type: "application/pdf", lastModified: Date.now() });
//document.body.append(file);
//var blob=new Blob([e], {type:"application/pdf"});
var link=document.createElement('a');
//link.href=window.URL.createObjectURL(e);
link.download=file;
link.click();
}, onFailure: function(error){
alert(error);
}
};