好的,我在s3的公共存储桶上进行了此工作,我直接使用sdk进行了调用。当我切换到预签名时,它停止工作,看起来预签名以不同的方式发送pdf。
这是我要查看pdf的对象。
<object id="first" data="" type="application/pdf" style="min-height: 585px; min-width:500px; width: 100%; height: 100%">
<p>It appears you don't have a PDF plugin for this browser.
you can <a [href]="firstUrl">click here to
download the PDF file.</a></p>
</object>
在我的ngOnInit中,我调用了一个名为getPdfs();的函数。
let storedFiles;
this.preSign.getList(this.org, this.id)
.subscribe( result => {
storedFiles = result;
let first = this.getPdfFromList(this.form + '.pdf', storedFiles);
this.preSign.downloadFile(first.url)
.subscribe( resultt => {
this.displayPdf(resultt._body, '#first');
});
});
然后显示Pdf
displayPdf(file, part){
$(part).attr('data', URL.createObjectURL(new Blob( [ file ], { type: 'application/pdf' } )));
}
我可以正确下载并保存pdf,但无法在对象中查看。 pdf在对象内部将非常不正确地显示。要么只显示灰色框,要么完全空白。
在我使用公共存储桶之前,这就是我所使用的。
$('#first').attr('src', URL.createObjectURL(new Blob( [ new Uint8Array( result.data.Body ) ], { type: 'application/pdf' } )));
当我尝试在预先签名的地址上使用Uint8Array时,它会显示“无法显示PDF”,然后有一个重新加载按钮。