开发者

Uploading a byte array to a HTTP server

I would like to upload a byte array to a HTTP(S) server. I am aware that this can be done using the WebClient but I would like to send some POST arguments along with the byte array.

How can I do this with more fundemental classes like HTTPWebRequest? These are the conditions that the solution should m开发者_JS百科eet:

  • It should also work in HTTPS.
  • It should not require the byte array to be written to a temporary file. What I mean is that I should be able to do everything right within the memory.

Also, if the solution requires something different to be done over the server side, it would be great if you also state that.

Thanks in advance.


You should check this question: Multipart forms from C# client
especially this answer:
https://stackoverflow.com/a/769093/213550

There is a lot of code, but the main idea is:

  1. Set the Request's ContentType to the multipart/form-data
  2. Add the boundary and the byte array to the Request's body
  3. Get the Response.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜