I'm trying to upload a file using ASIFormDataRequest
ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString: uploadUrl]] autorelease];
[request setPostValue:md5sum forKey:@"md5sum"];
[request setFile:[NSString stringWithFormat:@"%@", filePath] forKey:@"database"];
[request startSynchronous];
This logs an error:
"No file exists at: file://localhost/Users/thomas/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/36115C00-9352-4CD4-B5C2-C3A1CD6041FF/Documents/foo.sqlite"
However when I try the path in my browser. It downloads the file straight away, so the file does exist.
Anyone got a clue?
Th开发者_高级运维anks!
Try to use POSIX path:
[request setFile:[[NSURL URLWithString:filePath] path] forKey:@"database"];
I suspect it's the %20
that makes troubles. Try unescaping the filePath
variable:
filePath = [filePath stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
精彩评论