iOS загрузка AVCapture записанного видео на сервер через AFNetworking 3.0 Multipart

I record video thorough using AVCapture and pass that video url to next controller where i have AVPlayer, which play video fine and using this code to upload video on server,when i call this form viewDidAppear it is working fine but when i call this in button action request body is missing, meanig that server didn’t get the video.Любой человек имеет представление о том, что я упускаю или делаю неправильно.


[userInfoDict setValue:[[NSUserDefaults standardUserDefaults] valueForKey:@"latitude"] forKey:@"latitude"];
[userInfoDict setValue:[[NSUserDefaults standardUserDefaults] valueForKey:@"longitude"] forKey:@"longitude"];

     _request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"serverURL" parameters:userInfoDict constructingBodyWithBlock:^(id<AFMultipartFormData> formData){
    NSLog(@"nn requrst time out is%fnn", [_request timeoutInterval]);

    [formData appendPartWithFileURL:testPAth name:@"video" fileName:@"" mimeType:@"video" error:nil];

    NSLog(@"n video yp upload %@nn",_videoUrl);
    // got video video url like this
} error:nil];

[self.view addSubview:_playerProgress];

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

_uploadTask = [manager
              progress:^(NSProgress * _Nonnull uploadProgress)


                  dispatch_async(dispatch_get_main_queue(), ^{

                    [_playerProgress setProgress:uploadProgress.fractionCompleted];

                      NSLog(@"nuploading video vlaues %fn",uploadProgress.fractionCompleted);


              completionHandler:^(NSURLResponse * _Nonnull response, id  _Nullable responseObject, NSError * _Nullable error) {
                  if (error) {
                      NSLog(@"Error: %@", error);

                      [_playerProgress setHidden:YES];

                  } else

                      NSLog(@"%@ ", response);

                      [_playerProgress setHidden:YES];

                      NSLog(@"nn REsponse Form Server %@nn",responseObject);



[_uploadTask resume];


1 ответ

  1. изменить это :

    [formData appendPartWithFileURL:testPAth name:@"video" fileName:@"" mimeType:@"video/quicktime" error:nil];