-2

I am sending a wav file using the following code, however, the process stops at

Sent 131072 of 141359 bytes     

So? Is there some problem with the code? Or am i missing something?

NSString *vidURL = [[NSBundle mainBundle] pathForResource:@"M1F1-int24WE-AFsp" ofType:@"wav"];
                NSData *videoData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:vidURL]];



                NSURL *url = [NSURL URLWithString:@"http://apps2.mobiiworld.com"];
                AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
                //  NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"Romantic.jpg"], 0.5);
                NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:@"/staging/krafttesting/upload.php" parameters:nil constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
                    [formData appendPartWithFileData:videoData name:@"file" fileName:@"recording.wav" mimeType:@"audio/vnd.wave"];
                }];

                AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
                [operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
                    NSLog(@"Sent %lld of %lld bytes", totalBytesWritten, totalBytesExpectedToWrite);
                }];
                // [httpClient enqueueHTTPRequestOperation:operation];

                [operation  setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {NSLog(@"Success");}
                                                  failure:^(AFHTTPRequestOperation *operation, NSError *error) {


                                                      NSLog(@"error: %@",  operation.responseString);


                                                      NSLog(@"error: %@", error.userInfo);




                                                  }];
                [operation start];
ScarletWitch
  • 522
  • 6
  • 23
  • In order to figure what's going wrong, we need as much info as possible. So, wait until the connection is finished (possibly timed out) and log the errors and any other important info: status code of the response and response data (if any), any error messages logged or returned from AFN. – CouchDeveloper Jun 27 '13 at 09:00
  • 1
    The connection never times out. The app just hangs and nothing happens. I kept it overnight to find the issue. But the connection never timed out. – ScarletWitch Jun 27 '13 at 09:10
  • It *must* time out eventually, or finish with a response. Let it run in the debugger. Then when it appears to hang, interrupt the program via the stop button (looks like [||]) in the debugger pane. Then click the thread view in the navigator area and look where every thread has been halted. This should reveal more information. – CouchDeveloper Jun 27 '13 at 09:26

1 Answers1

0

I got the solution. It seems AFHTTPClient works only when ARC is on. I had ARC off, due to which it was not working - Though i had no errors received.

ScarletWitch
  • 522
  • 6
  • 23