Note that there are some explanatory texts on larger screens.

plurals
  1. POimage base64 corrupt post (Objective-C)
    primarykey
    data
    text
    <p>I'm trying to send a post with several parameters and include an image in base64.</p> <p>The image coding does it well, I checked the base64 image in a online base64 to image converter and looks like the image is encoded successfully. I can do the post process without any problem, but when I download it, the log shows this error:</p> <blockquote> <p>Error: ImageIO: JPEG Corrupt JPEG data: 120 extraneous bytes before marker 0xf1<br> Error: ImageIO: JPEG Unsupported marker type 0xf1</p> </blockquote> <p>I do this in a method</p> <pre><code>jpgData = UIImageJPEGRepresentation(image, 0.1f); imageString = [jpgData base64EncodedStringWithOptions:0]; </code></pre> <p>And this is the method that sends the post, which is where I think the error is.</p> <pre><code>- (void)putComment{ dispatch_queue_t backgroundQueue = dispatch_queue_create("com.mycompany.myqueue", 0); __block int responseCode = 0; dispatch_async(backgroundQueue, ^{ NSString *requestParams = [NSString stringWithFormat: @"idAdvertiser=%@&amp;idUserDevice=%@&amp;image=%@&amp;text=%@&amp;userName=%@&amp;groups=%@", ADVERTISER_ID, idUserDevice, imageString, texto, userName, groups]; [requestParams stringByReplacingOccurrencesOfString:@"+" withString:@"%2B"]; NSData *postData = [requestParams dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; // NSData *postData = [requestParams dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLenght = [NSString stringWithFormat:@"%d", [postData length]]; NSMutableURLRequest *request = [NSMutableURLRequest new]; [request setURL:[NSURL URLWithString: URL_COMMENT]]; [request setHTTPMethod:@"POST"]; [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; [request setHTTPShouldHandleCookies:NO]; [request setValue:postLenght forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/x-www-form-urlencoded charset=utf-8" forHTTPHeaderField:@"Current-Type"]; [request setHTTPBody:postData]; [request setTimeoutInterval:40]; NSError *error = nil; NSHTTPURLResponse *response; NSData *responseData = [NSURLConnection sendSynchronousRequest: request returningResponse: &amp;response error: &amp;error]; }); } </code></pre> <p>The server side works perfectly (tested in an Android app), so the problem is not server related.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload