我正在尝试使用我的团队创建的 API,该 API 返回移动设备的 FileContentResult(PDF 文件)。
我已经编写了一些代码来检索该结果的字节数组,如下所示。
在 API 中返回 PDF 文件的行
return new FileContentResult(result.Data.Data, "application/pdf");
我的代码
public class QuoteCoreService : BaseService, IQuoteCoreService
{
public QuoteCoreService(IService<CollaborationClient> httpClient, IAuthenticationService authenticationService) : base(httpClient, authenticationService)
{
}
public byte[] GetSampleTag(string QuoteId)
{
var headers = BuildHeaders();
byte[] result;
try
{
result = _httpClient.Get<byte[]>("SampleTagUpdate/PDFFile/" + QuoteId, headers).Result;
}
catch(Exception e)
{
Crashes.TrackError(e, new Dictionary<string, string> { { "GetSampleTag()", "HTTP Call to service" } });
result = null;
}
return null;
}
}
IService 只是 HttpClient,在后台添加了一些基本配置。我希望 _httpClient.Get 行返回一个字节数组。