我从Web服务标注中获取了Blob内容,要求在浏览器中显示文件。
是)我有的:
在blob参数上方,我将其作为响应并将其发送回“回调”中的javascript方法。我正在尝试将Blob转换为相应的文件格式并在浏览器上查看(除非最终用户希望,否则我不想下载)。
我在下面尝试过:
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);
}
};
Run Code Online (Sandbox Code Playgroud)