Почему это действие ничего не вернет? Метод DownloadCallVoiceFile работает хорошо
public virtual async Task DownloadCallVoiceFile(string uniqueId, CancellationToken cancellationToken)
{
var callReport = await _callCenterService.DownloadCallVoiceFile(uniqueId, cancellationToken); //CallReport is MemoryStream and Everything is okey
return File(callReport, "audio/wav","1.wav"); //but here is problem... Return Nothing
}
Он даже правильно сохраняет файл на сервере... Посмотрите это:
public virtual async Task DownloadCallVoiceFile(string uniqueId, CancellationToken cancellationToken)
{
var callReport = await _callCenterService.DownloadCallVoiceFile(uniqueId, cancellationToken);
using (FileStream file = new FileStream("C:\\Users\\Ya\\Desktop\\TestFile.wav", FileMode.Create, FileAccess.Write))
callReport.CopyTo(file); //Just For Test... File Is Okey
return File(callReport, "audio/wav","1.wav");
}
Однако я не думаю, что в этом есть необходимость
Но для получения дополнительной информации см. метод:
public class SshServices
{
private static SftpClient? s_sftpClient; //using Renci.SshNet
public async Task DownloadCallVoiceFile(string uniqueId,CancellationToken cancellationToken)
{
s_sftpClient = new SftpClient("host", "user", "password");
await s_sftpClient.ConnectAsync(CancellationToken.None);
if (s_sftpClient != null && s_sftpClient.IsConnected)
{
var serverAddress = @"\file\monitor\saved\Voice.Wav";
var stream = new MemoryStream();
var result = s_sftpClient.BeginDownloadFile(serverAddress, stream);
do
{
await Task.Delay(100, cancellationToken);
}
while (result == null || !result.IsCompleted);
if (result != null && result.IsCompleted) s_sftpClient.EndDownloadFile(result);
s_sftpClient.Disconnect();
stream.Position = 0;
return stream; //Return Is Okey And stream Is not Null
}
else
{
throw new Exception();
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... annot-retu