本文介绍了上传时RestSharp加载整个文件到内存中。如何避免呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用RestSharp在Mono项目上传一些文件,我已经注意到,当一个大文件上传,存储大幅度增长。

I'm using RestSharp in a Mono project to upload some files and I have noticed that when a large file is uploaded, the memory grows substantially.

看着我也注意到, RestSharp源$ C ​​$ C FileParameter预计一个字节数组,这意味着它真​​的是加载文件到内存中。

Looking at RestSharp source code I did notice that FileParameter expects a byte array, which means it is really loading the file into memory.

我是不是做错了什么?有没有办法为RestSharp无法做到这一点?我可能真的上传大文件的话,从内存中上传他们是不是一种选择。

Am I doing something wrong? Is there a way for RestSharp not do this? I might be uploading really large files so, uploading them from memory is not an option.

任何帮助(包括告诉我要利用现有的单声道另一个HTTP库)是值得欢迎的。

Any help (including telling me to use another HTTP library available on mono) is welcome.

推荐答案

和我放弃了后,我发现的这一行,因此要求机构总是加载到内存中,这是不幸的,所以我建立了一个简单的解决方案的基础上,从this问题和调试的Apache HttpClient库

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.

这篇关于上传时RestSharp加载整个文件到内存中。如何避免呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-01 06:20