A
A
andoral2018-03-06 10:45:56
C++ / C#
andoral, 2018-03-06 10:45:56

Why does Image.FromStream throw "Invalid Parameter"?

Throws on the line

var image = Image.FromStream(httpListenerContext.Request.InputStream);

I make a request through Postman, in the png body

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
cicatrix, 2018-03-06
@andoral

From your question, little is clear, I'll try to use telepathy.
Most likely, you are developing a web application.
Most likely, you are trying to upload a file through the web interface.
If my assumptions are correct, then it's worth starting with the fact that, probably, the only way to download a file from a browser at the moment is a POST request in the multipart/form-data format . If so, the incoming stream from the request does not only contain your file. The binary data of the picture is also "wrapped" with additional service information. Follow the link, in the article on Wikipedia there is a direct example of the content of your incoming stream.
If you are using websockets for some reason (moreover, implementing the http protocol), then more details are needed to help you.

F
freeExec, 2018-03-06
@freeExec

Here's what they write on MSDN:

Comments
You must keep the stream open for the lifetime of the Image.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question