我正在API中创建一个流文件并将其返回给客户端,但是客户端会获取默认的安培流。我该怎么办?
API中的代码
while (!File.Exists(fileName));
using (stream = new FileStream(fileName, FileMode.Open))
{
streamcontent = new StreamContent(stream);
return streamcontent;
}
客户端中的代码
var result = await _httpClient.GetAsync($"GetFileStream/{CurrentClient.Id}/{_invoiceYear}/{_invoiceMonth}");
if (result.IsSuccessStatusCode)
{
var stream = await result.Content.ReadAsStreamAsync();
_fileSaver.SaveStreamToFile(stream, _storageFile);
}