문제

I am trying to upload large video file using nsurconnection in iphone 3gs.But its failing.The app crashes without any logs.The same code is working fine in iphone4. I would like to know if this is some memory limitation issue. The 3gs is uploading small videos with same code. It only fails for large size videos

here is the code i used:

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];
도움이 되었습니까?

해결책

Have you tried streaming the HTTP body, rather than using an NSData?

Replace

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

with

NSInputStream *videoStream = [[[NSInputStream alloc] initWithURL:videoPathUrl] autorelease];
[request setHTTPBodyStream:videoStream];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top