• AFN实现多图片上传的方法


    [[AFAppDotNetAPIClient sharedClient] POST:path parameters:dic constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
            
            if (fieldArr != nil) {
                for (int i = 0; i<fieldArr.count; i++) {
                    
                    NSArray *photoArr = photoDic[fieldArr[i]];
                    
                    NSArray *cameraArr = cameraDic[fieldArr[i]];
                    
                    NSArray *voiceArr = voiceDIc[fieldArr[i]];
                    
                    NSString *ename =  enameDic[fieldArr[i]];
                    if (photoArr != nil) {
                        for (NSInteger i = 0; i<photoArr.count; i++) {
                            if ([photoArr[i] objectForKey:@"attach_id"] == nil ) {
                                NSData *imageData = [NSData dataWithContentsOfFile:[[photoArr objectAtIndex:i] objectForKey:@"path"]];
                                NSString *paramName = [NSString stringWithFormat:@"%@_%ld",[photoArr[i]objectForKey:@"ename"],(long)i];
                                NSArray *fileNameArray = [[[photoArr objectAtIndex:i] objectForKey:@"path"] componentsSeparatedByString:@"/"];
                                NSString *fileName = fileNameArray[[fileNameArray count]-1];
                                [formData appendPartWithFileData:imageData name:paramName fileName:fileName mimeType:@"image/*"];
                            }
                            
                            
                        }
                    }
    北京-Alexyeee_  16:12:02
    没写完。。。自行脑补。。

  • 相关阅读:
    codeforces 349B Color the Fence 贪心,思维
    luogu_2022 有趣的数
    luogu_2320 [HNOI2006]鬼谷子的钱袋
    luogu_1879 [USACO06NOV]玉米田Corn Fields
    SAC E#1
    luogu_1984 [SDOI2008]烧水问题
    luogu_2085 最小函数值
    luogu_1631 序列合并
    luogu_1196 银河英雄传说
    luogu_1037 产生数
  • 原文地址:https://www.cnblogs.com/lidongxiao/p/5148666.html
Copyright © 2020-2023  润新知