AFNetworking + WCF Streaming未按预期工作(所有数据都在客户端缓冲)

时间:2015-02-15 10:47:38

标签: c# objective-c wcf afnetworking

所以经过大量的游戏,从RESTKit变为基础AFNetworking后,我们仍然无法按预期的方式进行流式传输。

我们正在将文件流式传输到WCF服务器:

RKObjectManager* manager = [RKObjectManager sharedManager];

// Build the request
NSMutableURLRequest* request = [manager.HTTPClient requestWithMethod:@"PUT" path:action parameters:nil];


// note - this method inserts all parameters to the URL. so we will construct a new URL and add the parameters
// this line is taken from AFNetworking.

    // we set the file name in the URL
    NSURL* url = [NSURL URLWithString:[[request.URL absoluteString] stringByAppendingFormat:[action rangeOfString:@"?"].location == NSNotFound ? @"?%@" : @"&%@", AFQueryStringFromParametersWithEncoding(params, manager.HTTPClient.stringEncoding)]];
    [request setURL:url];

// all requests will have a stream type (as we are posting raw data)
[request setValue:[NSString stringWithFormat:@"application/octet-stream"] forHTTPHeaderField:@"Content-Type"];


// we are overriding any body that the request added - because we want the whole rawData to be sent as a body. Data streaming.
[request setHTTPBodyStream:dataStream];



// Set the upload timeout
[request setTimeoutInterval:999999];

AFHTTPRequestOperation* httpOp =[manager.HTTPClient HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {

    NSLog(@"sucesS");

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

    NSLog(@"Failure");

}];

[httpOp setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {

    NSLog(@"uploading..");

}];

[manager.HTTPClient enqueueHTTPRequestOperation:httpOp];

我看到代理被立即调用并且写入的字节不断增加。 但是服务器没有收到 ANYTHING 调用成功后,,服务器开始处理文件。

我们的服务器端网络配置:

  <endpoint address="Upload" binding="webHttpBinding" bindingConfiguration="webUploadHttpBindingConfig" behaviorConfiguration="web" contract="IREST" />


 ...

 <binding name="webUploadHttpBindingConfig" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="Transport">
                    <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
                </security>
            </binding>

在服务器代码中我们创建文件并将其流式传输到磁盘。

我把头发拉出来,这里缺少什么?

感谢。

0 个答案:

没有答案