MKSG-MugunthKumar / MKNetworkKit

Modern NSURLSession based Networking Framework with built in authentication and HTTP 1.1 caching standards support for iOS 8+ devices
http://mk.sg/8w
3.06k stars 755 forks source link

Post data format error #469

Open gonghongxia opened 8 years ago

gonghongxia commented 8 years ago

MKNetworkKit Tag 0.87 change "MKNetworkOperation.m" file. Now status: -(NSData) bodyData { .......... [self.dataToBePosted enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL stop) { NSString *thisFieldString = [NSString stringWithFormat: @"--%@\r\nContent-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\nContent-Type: %@\r\nContent-Transfer-Encoding: binary\r\n\r\n", boundary, thisDataObject[@"name"], thisDataObject[@"filename"], thisDataObject[@"mimetype"]];

      [body appendData:[thisFieldString dataUsingEncoding:[self stringEncoding]]];
      [body appendData:thisDataObject[@"data"]];
      [body appendData:[@"\r\n" dataUsingEncoding:[self stringEncoding]]];
  }

}]; .......... }

Right status: -(NSData) bodyData { .......... NSDictionary *thisDataObject = (NSDictionary) obj; if([self.request.HTTPMethod isEqualToString:@"PUT"]){ [body appendData:thisDataObject[@"data"]]; }else{ NSString *thisFieldString = [NSString stringWithFormat: @"--%@\r\nContent-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\nContent-Type: %@\r\nContent-Transfer-Encoding: binary\r\n\r\n", boundary, thisDataObject[@"name"], thisDataObject[@"filename"], thisDataObject[@"mimetype"]];

      [body appendData:[thisFieldString dataUsingEncoding:[self stringEncoding]]];
      [body appendData:thisDataObject[@"data"]];
      [body appendData:[@"\r\n" dataUsingEncoding:[self stringEncoding]]];
  }

.......... }