douba4824 2014-06-14 14:03
浏览 78

NSInvalidArgumentException使用AFNetworking将音频发送到服务器

I am trying to send an audio file to my server using AFNetworking but so far without success. This is the code on my device:

self.manager = [AFHTTPRequestOperationManager manager];
[self.manager POST:@"upload.php"
    parameters:@{}
    constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
        [formData appendPartWithFileData:self.output.soundData name:@"audio" fileName:@"recordedSound.m4a" mimeType:@"audio/m4a"];
    } success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"JSON: %@", responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error: %@", error);
    }];

This is my code on the server:

<?php

define("WWW_ROOT",dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR);

if (!empty($_FILES)) {
    $target_path = WWW_ROOT ."uploads/";
    $target_path = $target_path . basename( $_FILES['audio']['name']); 
    move_uploaded_file($_FILES['audio']['tmp_name'], $target_path);
} 

Whenever I try to send the data to the server, I get this error:

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -streamStatus only defined for abstract class. Define -[AFMultipartBodyStream streamStatus]!'

  • 写回答

1条回答 默认 最新

  • doujian1954 2014-08-11 19:01
    关注

    same here just update AFNetworking to latest version and everything should work smooth.

    评论

报告相同问题?

悬赏问题

  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64