zoukankan      html  css  js  c++  java
  • 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
    没写完。。。自行脑补。。

  • 相关阅读:
    Balance的数学思想构造辅助函数
    1663. Smallest String With A Given Numeric Value (M)
    1680. Concatenation of Consecutive Binary Numbers (M)
    1631. Path With Minimum Effort (M)
    1437. Check If All 1's Are at Least Length K Places Away (E)
    1329. Sort the Matrix Diagonally (M)
    1657. Determine if Two Strings Are Close (M)
    1673. Find the Most Competitive Subsequence (M)
    1641. Count Sorted Vowel Strings (M)
    1679. Max Number of K-Sum Pairs (M)
  • 原文地址:https://www.cnblogs.com/lidongxiao/p/5148666.html
Copyright © 2011-2022 走看看