
- (voID)uploadVIDeoAtLocalPath:(Nsstring *)vIDeoPath vIDeoID:(Nsstring *)vIDeoID userID:(Nsstring *)userID { Nsstring *strServerURL = @"www.mysite.com/user/uploadVIDeo"; NSURL *URL = [NSURL URLWithString:strServerURL]; AFhttpClIEnt *clIEnt = [AFhttpClIEnt clIEntWithBaseURL:URL]; NSMutableURLRequest *request = [clIEnt multipartFormRequestWithMethod:@"POST" path:@"" parameters:nil constructingBodyWithBlock: ^(ID <AFMultipartFormData>formData) { // userID NSData *userIDData = [userID dataUsingEnCoding:NSUTF8StringEnCoding]; [formData appendPartWithFormData:userIDData name:@"userID"]; // vIDeoID NSData *vIDeoIDData = [vIDeoID dataUsingEnCoding:NSUTF8StringEnCoding]; [formData appendPartWithFormData:vIDeoIDData name:@"vIDeoID"]; // vIDeo NSData *vIDeoData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:vIDeoPath]]; [formData appendPartWithfileData:vIDeoData name:@"vIDeo" filename:@"vIDeo.mov" mimeType:@"vIDeo/quicktime"]; }]; [request setURL:URL]; [request setTimeoutInterval:60.0]; [request sethttpMethod:@"POST"]; AFhttpRequestoperation *operation = [[AFhttpRequestoperation alloc] initWithRequest:request]; [AFhttpRequestoperation addAcceptableStatusCodes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(100,500)]]; [operation setCompletionBlockWithSuccess: ^(AFhttpRequestoperation *operation,ID responSEObject) { NSLog(@"Response String: %@",operation.responseString); } failure:^(AFhttpRequestoperation *operation,NSError *error) { NSLog(@"Failure: %@",error); }]; [clIEnt enqueuehttpRequestoperation:operation];} 任何人都可以让我知道我是否正确吗?如果没有,有人可以告诉我如何将视频上传到网络服务以及其他参数吗?
感谢大家!
解决方法 我用这种方法不太好.我遇到过同样的问题.但是,我已经修好了它,就像混合POST和amp; GET方法.我刚刚将参数发送为GET方法,如下所示 –Nsstring *strServerURL = [Nsstring stringWithFormat:@”www.mysite.com/user/uploadVIDeo&userID=%d&vIDeoID=%d”,1,55];
并按照您的方法以POST方式发送我的视频数据 –
NSMutableURLRequest *request = [clIEnt multipartFormRequestWithMethod:@"POST" path:@"" parameters:nil constructingBodyWithBlock: ^(ID <AFMultipartFormData>formData) { // vIDeo NSData *vIDeoData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:vIDeoPath]]; [formData appendPartWithfileData:vIDeoData name:@"vIDeo" filename:@"vIDeo.mov" mimeType:@"vIDeo/quicktime"];}]; 您最好尝试修改您的Web服务并尝试上述方式.它应该有效.
干杯!
总结以上是内存溢出为你收集整理的ios – AFNetworking – 上传视频和其他参数全部内容,希望文章能够帮你解决ios – AFNetworking – 上传视频和其他参数所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)