1
私は自分のコードでストリーミングを有効にしましたが、大きなファイルをアップロードするのに時間がかかりました。次のようなことが起こります:WCFストリーミングが長すぎます
私のWPFコードは、ファイルをアップロードするためにサービスを呼び出しますが、サービス上のデバッガは長時間経過してもヒットしません。 10 MBファイルの場合、約1.07分かかります。コードの呼び出し
:
using (System.IO.FileStream stream = new System.IO.FileStream(fileInfo.FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
uploadRequestInfo.FileName = fileInfo.Name;
uploadRequestInfo.Length = fileInfo.Length;
uploadRequestInfo.FileByteStream = stream;
clientUpload.UploadFile(uploadRequestInfo);
}
運用契約:
public partial class RemoteFileInfo {
[System.ServiceModel.MessageHeaderAttribute(Namespace="http://tempuri.org/")]
public string FileName;
[System.ServiceModel.MessageHeaderAttribute(Namespace="http://tempuri.org/")]
public long Length;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://tempuri.org/", Order=0)]
public System.IO.Stream FileByteStream;
public RemoteFileInfo() {
}
public RemoteFileInfo(string FileName, long Length, System.IO.Stream FileByteStream) {
this.FileName = FileName;
this.Length = Length;
this.FileByteStream = FileByteStream;
}
}
のapp.config:
<binding name="BasicHttpBinding_ITransferService" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>