Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Post data format error #469

Open
gonghongxia opened this issue Dec 18, 2015 · 0 comments
Open

Post data format error #469

gonghongxia opened this issue Dec 18, 2015 · 0 comments

Comments

@gonghongxia
Copy link

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]]];
  }

..........
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant