【发布时间】:2020-05-17 03:22:01
【问题描述】:
我的服务器端有一个本地路径,我必须以角度获取它并显示它, 我该怎么做? 如果有人能告诉我路,我会很高兴 我知道我需要在 angular 中使用 blob,但是我从服务器获取/返回哪些参数?
这是我的 Angular 代码
openPDF(){
this.ser.openDPFfile().subscribe((response)=>{
let file = new Blob([response.byteString], { type: 'application/pdf' });
var fileURL = URL.createObjectURL(file);
window.open(fileURL);
}) }
和我的 C# 代码
[RoutePrefix("api/files")]
[Route("download")]
[HttpGet]
public string GetStreamFile()
{
string fileName = "LabResult.pdf";
string path = @"C:/Users/" + fileName;
byte[] a = File.ReadAllBytes(path);
string s = Convert.ToBase64String(a);
return s;
}
我需要添加或更改什么? 请帮我 谢谢:)
【问题讨论】: