我正在尝试将大文件上传到IIS中托管的WCF服务.
我正在使用Restful和Streaming方法.
但我无法上传超过64KB的文件.
我通过更改文件中所有与大小相关的元素尝试了很多web.config,但未能解决问题.
这是我的代码和配置,请告诉我是否有人在代码中发现任何问题以及如何解决.
运营合同
[OperationContract]
[WebInvoke(UriTemplate = "/UploadImage/{filename}")]
bool UploadImage(string filename, Stream image);
Run Code Online (Sandbox Code Playgroud)
执行合同
public bool UploadImage(string filename, Stream image)
{
try
{
string strFileName = ConfigurationManager.AppSettings["UploadDrectory"].ToString() + filename;
FileStream fileStream = null;
using (fileStream = new FileStream(strFileName, FileMode.Create, FileAccess.Write, FileShare.None))
{
const int bufferLen = 1024;
byte[] buffer = new byte[bufferLen];
int count = 0;
while ((count = image.Read(buffer, 0, bufferLen)) > 0)
{
fileStream.Write(buffer, 0, count);
}
fileStream.Close();
image.Close();
}
return true;
} …Run Code Online (Sandbox Code Playgroud) wcf ×1