RestSharp is loading the whole file into memory when uploading. How to avoid it?

陌路散爱 提交于 2019-11-30 14:03:46

Use the AddFile(name, writer, filename) overload.

For the writer parameter, pass an Action<Stream> that writes directly to the request body stream. Do not close the stream.

Here's an example for writing to the stream.

Maurício Linhares

And I gave up after I found this line, so request bodies are always loaded into memory, which is unfortunate, so I built a simple solution to do file uploads based on code from this question and from debugging the Apache HttpClient library.

In case someone is interested, the source is available here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!