Pergunta

I have a problem when I POST a JPEG file with WebClient. I have converted my "image.jpg" to byte [], I send it to the Web Service but the image is corrupted. There is a specific way to convert a JPEG file to byte []?

Thanks for your help.

Foi útil?

Solução

There is no specific way. Files are just files to the system it does not care if it is a image, video or a dll.

To read a file into a byte stream you can use:

File.ReadAllBytes(fileName);

I personally would use EasyHTTP (https://github.com/hhariri/EasyHttp) to post the file stream:

HttpClient client = new HttpClient();
client.Post(URL, ByteStream, ContentType);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top