On client side I use ASIHttpRequest to upload a pict:
// upload on server
NSLog(@"Upload to server");
UIImage *im = [UIImage imageNamed:@"ok.png"];
NSData *da = UIImageJPEGRepresentation(im, 0.6);
NSLog(@"DATA:%@", da);
NSString *n = [NSString stringWithFormat:@"%@/upload", @"http://localhost:3000"];
NSURL *url = [NSURL URLWithString:n];
NSLog(@"URL:%@",url);
ASIFormDataRequest *r = [ASIFormDataRequest requestWithURL:url];
[r setData:da
withFileName:@"myphoto.ico"
andContentType:@"image/jpeg"
forKey:@"photo"];
[r setRequestMethod:@"POST"];
[r setShouldAttemptPersistentConnection:NO];
[r startSynchronous];
NSString *resp = [r responseString];
NSLog(@"RESPONSE:%@", resp);
On server side, I use node.js:
app.post('/upload', function(req, res){
console.log(req);
console.log(req.params);
});
The request on client side seems ok but when checking the log on server side I do not see any things linked to the data I sent. What is the correct way to retrieve the data on node.js in this case ?
Using Connect-Form and req.form.completed did the trick.