AFNetworking多部分mp4上传错误

时间:2015-10-18 16:47:11

标签: ios iphone afnetworking multipartform-data afnetworking-2

我正在尝试使用AFNetworking上传mp4视频。它给了我错误

file =         (
            "The file must be a file of type: mp3, jpeg, bmp, png, mp4, wmv, avi."
        );

以下是我用来上传的代码:

NSMutableURLRequest *request = [[AFJSONRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:webURL parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
       BOOL isAppended = [formData appendPartWithFileURL:[NSURL fileURLWithPath:filePathStr] name:@"file" fileName:@"report.mp4" mimeType:@"video/mp4" error:nil];
        if (isAppended) {
            NSLog(@"appended successfully!");
        }
    } error:nil];

    AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
    NSProgress *progress = nil;

    NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
        if (error) {
            NSLog(@"Error: %@", error);
        } else {
            NSLog(@"%@ %@", response, responseObject);
        }
        multiPartCallBack(response,responseObject,error);
    }];

    [uploadTask resume];

0 个答案:

没有答案