trying to post a byte array or memory stream with RestSharp.

I have tried the following

request.AddFile("stream", x => new MemoryStream(blocks.First().Value), "stream", "application/binary");

And

request.AddFile("stream", blocks.First().Value, "stream", "application/binary");

Where blocks.First().Value is a Byte Array

On the server end I am expecting a form with stream parameter in it that I can extract the bytes from.

Additional information: Adding null or string.Empty to AddFile sends the byte array

request.AddFile("stream", blocks.First().Value, string.Empty);

The problem is that it adds 2 bytes to each byte array sent (1 for carriage return and one for new line). And I cannot remove them on every post on server side since other clients do not behave this way.

Thank you for any input on this!

有帮助吗?

解决方案

We fixed it with a pull request in Nancy 0.11 so this is no longer an issue.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top