Skip to content

Instantly share code, notes, and snippets.

@oliveira-michel
Created March 18, 2020 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oliveira-michel/0ac3409e4912b2cff5aa92d9e0e63fc7 to your computer and use it in GitHub Desktop.
Save oliveira-michel/0ac3409e4912b2cff5aa92d9e0e63fc7 to your computer and use it in GitHub Desktop.
Exemplo de Cliente consumindo arquivo via HTTP
public void Teste()
{
var retorno = GetArquivo();
byte[] bytesImagem;
using (MemoryStream ms = new MemoryStream())
{
retorno.CopyTo(ms);
bytesImagem = ms.ToArray();
}
File.WriteAllBytes($"c:\\teste.png", bytesImagem);
}
public Stream GetArquivo()
{
var http = (HttpWebRequest) WebRequest.Create("http://xxxx/logo.png");
http.Method = "GET";
var response = http.GetResponse();
return response.GetResponseStream();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment