سؤال

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