Hello, I have 2.1 configured properly and am trying to upload an image from a native iOS app. The block of code I'm using to do the API call is as follows, I get an error 403 response with "invalid source (thumb)" as the response.
NSData* imgDataJpg = UIImageJPEGRepresentation(image, 1.0);
NSString* imgDataEncoded = [imgDataJpg base64Encoding];
NSMutableURLRequest *request = [NSMutableURLRequest
requestWithURL:[NSURL URLWithString"http://<mydomain>/chevereto/api.php"]];
NSString* kAPIKey = @"secretstuff";
NSMutableString* requestParams =
[NSMutableString stringWithFormat"key=%@&format=xml&upload=%@",
kAPIKey, imgDataEncoded];
[request setHTTPMethod"POST"];
[ request setValue"application/x-www-form-urlencoded" forHTTPHeaderField"content-type"];
[request setHTTPBody:[requestParams dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection* conn = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
Has anyone dealt with this before? I can see on the server that the uploaded image is invalid but appears to have the right size. Might be an issue with the base64 encoding. I've tried several options for doing this in iOS, they've all failed. Currently using Nick Lockwood's component, found here: https://github.com/nicklockwood/Base64
NSData* imgDataJpg = UIImageJPEGRepresentation(image, 1.0);
NSString* imgDataEncoded = [imgDataJpg base64Encoding];
NSMutableURLRequest *request = [NSMutableURLRequest
requestWithURL:[NSURL URLWithString"http://<mydomain>/chevereto/api.php"]];
NSString* kAPIKey = @"secretstuff";
NSMutableString* requestParams =
[NSMutableString stringWithFormat"key=%@&format=xml&upload=%@",
kAPIKey, imgDataEncoded];
[request setHTTPMethod"POST"];
[ request setValue"application/x-www-form-urlencoded" forHTTPHeaderField"content-type"];
[request setHTTPBody:[requestParams dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection* conn = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
Has anyone dealt with this before? I can see on the server that the uploaded image is invalid but appears to have the right size. Might be an issue with the base64 encoding. I've tried several options for doing this in iOS, they've all failed. Currently using Nick Lockwood's component, found here: https://github.com/nicklockwood/Base64