-2

我正在使用以下代码发送一个 wav 文件,但是,该过程在

Sent 131072 of 141359 bytes     

所以?代码有问题吗?还是我错过了什么?

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];
4

1 回答 1

0

我得到了解决方案。似乎 AFHTTPClient 仅在 ARC 开启时才有效。我关闭了 ARC,因此它无法正常工作 - 尽管我没有收到任何错误。

于 2013-06-27T12:36:44.103 回答