Created
March 18, 2020 20:31
-
-
Save oliveira-michel/0ac3409e4912b2cff5aa92d9e0e63fc7 to your computer and use it in GitHub Desktop.
Exemplo de Cliente consumindo arquivo via HTTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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