我有一个iis托管的wcf服务,其中包含一个获取文件并将其存储在服务器上的函数
我用一个6.5mb的文件做了一些测试,它花了我上传4.6分钟虽然它需要大约2分钟,
任何人都知道如何加快这个过程?我真的需要上传更快
ServiceManager.UploadFile(fileName, FilesHelper.FileToByteArray(filePath));
public static ServiceCallResult UploadFile(string fileName, byte[] data)
{
Stopwatch sw = Logger.StopwatchInit();
VsServiceClient vs = new VsServiceClient();
EndPointSelector(vs);
vs.InnerChannel.OperationTimeout = new TimeSpan(0, 10, 0);
try
{
bool result = vs.UploadMediaFile(fileName, data);;
sw.StopAndLog(fileName);
return new ServiceCallResult() { IsSuccessful = result };
}
catch (Exception ex)
{
sw.StopAndLog(fileName,ex);
return new ServiceCallResult() { IsSuccessful = false , Message = ex.Message };
}
finally
{
vs.Close();
}
}
<webHttpBinding>
<binding name="NewBinding0" maxBufferSize="160000000" maxBufferPoolSize="160000000"
maxReceivedMessageSize="160000000">
<readerQuotas maxDepth="160000000" maxStringContentLength="160000000"
maxArrayLength="160000000" maxBytesPerRead="160000000" maxNameTableCharCount="160000000" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="vsAjaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="vsServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service behaviorConfiguration="vsServiceBehavior" name="VsService">
<endpoint address="" behaviorConfiguration="vsAjaxBehavior" binding="webHttpBinding"
bindingConfiguration="NewBinding0" contract="VsService" />
</service>
Web服务在带有iis7的EC2小型实例服务器上运行,服务功能内部的代码需要不到1秒,因此所有浪费的时间都在客户端到服务器的传输上。
另一件事,服务器没有被使用,因此大多数时候只有一个用户使用它...
有什么想法吗?
由于