1

My code is below:

URL = "https://abcde.com/api//export/1234.wav?type=wav";
HttpResponseMessage response = client.GetAsync(URL).Result;

It's showing "StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent"

The StreamContent is a wav file, and file name is 1234.wav. How can I download the wav file from the HttpResponseMessage Steam Content response in C#?

Thanks a lot.

Pavel Kovalev
  • 7,521
  • 5
  • 45
  • 67
Leo.Z
  • 11
  • 2

1 Answers1

-1

From within your HttpResponse object there will be a response field. You have several options. What you want to do is use ReadAsStreamAsync().Result;

This will output a stream of the content within your HttpResponse message.

Read more about httpcontent here

Jlalonde
  • 483
  • 4
  • 13
  • Thanks, but could you tell me how to use the stream to download the file? Or I don't need it? – Leo.Z Mar 11 '19 at 23:41
  • So, not an expert here with wav files. But if you look [here](https://stackoverflow.com/questions/3502408/opening-an-audio-wav-file-from-a-memorystream-to-determine-the-duration) they use a memory stream to use a wav file. So if you have it in stream file, it's just a process of how do we particularly use our bytes – Jlalonde Mar 12 '19 at 00:09