Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 18th, 2012  |  syntax: None  |  size: 0.95 KB  |  hits: 29  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. AFNetworking post image in nested json
  2. {"product" : {
  3.   "catalogue_id" : "x",
  4.    "name" : "my product",
  5.    "image" : #<image>
  6.   }
  7. }
  8.        
  9. {"product" : {
  10.   "catalogue_id" : "x",
  11.    "name" : "my product"
  12.   } ,
  13.    "image" : #<image>
  14. }
  15.        
  16. NSMutableURLRequest *request = [[client sharedInstance]
  17.                          multipartFormRequestWithMethod:@"POST"
  18.                                                    path:@"/catalogues/1/products.json"
  19.                                              parameters:params
  20.                               constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
  21.                                   [formData appendPartWithFileData:img
  22.                                                               name:@"product[image]"
  23.                                                           fileName:@"myimage.jpg"
  24.                                                           mimeType:@"image/jpg"];
  25.                                   }];