iOS form-data表单提交

2020-09-11  本文已影响0人  可乐小子

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy defaultPolicy];
securityPolicy.validatesDomainName = NO;
securityPolicy.allowInvalidCertificates = YES;
manager.securityPolicy = securityPolicy;

NSDictionary  *params = (NSDictionary *)data;
[manager    POST:[NSString stringWithFormat:@"%@%@",APP_SERVER_ADDRESS,path]  parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
     NSLog(@"formData  === %@",formData);
} progress:^(NSProgress * _Nonnull uploadProgress) {
     NSLog(@"uploadProgress  === %@",uploadProgress);
} success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
    NSLog(@"reposbObject === %@",responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
    NSLog(@"error  === %@",error);
}];
上一篇 下一篇

猜你喜欢

热点阅读