2

iphone 3gsでnsurconnectionを使用して大きなビデオファイルをアップロードしようとしていますが、失敗します。アプリはログなしでクラッシュします。同じコードがiphone4で正常に機能しています。これがメモリ制限の問題であるかどうかを知りたいのですが。3gsは同じコードで小さな動画をアップロードしています。大きなサイズのビデオでのみ失敗します

これが私が使用したコードです:

NSMutableURLRequest *request=[[NSMutableURLRequest alloc]
                                              initWithURL:[NSURL URLWithString: urlString]
                                              cachePolicy:NSURLRequestUseProtocolCachePolicy
                                              timeoutInterval:6000.0];


            [request setHTTPMethod:@"POST"];
            [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
            [request setValue:@"application/x-www-form-urlencoded; boundary=AaB03x" forHTTPHeaderField:@"Content-Type"];

            NSLog(@"VideoPathD:%@",videoPathUrl);
            NSError *error;
            [request setHTTPBody: [NSData dataWithContentsOfURL:videoPathUrl options:0 error:&error]];


            [NSURLConnection connectionWithRequest:request delegate:self];
4

1 に答える 1

1

?を使用するのではなく、HTTPボディをストリーミングしてみましたNSDataか?

交換

[request setHTTPBody: [NSData dataWithContentsOfURL:videoPathUrl options:0 error:&error]];

NSInputStream *videoStream = [[[NSInputStream alloc] initWithURL:videoPathUrl] autorelease];
[request setHTTPBodyStream:videoStream];
于 2012-10-16T15:56:22.187 に答える