I referred to remove whitespaces from base64 encoded string when posting but still I have this problem
I am currently using the following code :
NSString *TrimBase64String=[base64String stringByReplacingOccurrencesOfString:@" " withString:@""];
I referred to remove whitespaces from base64 encoded string when posting but still I have this problem
I am currently using the following code :
NSString *TrimBase64String=[base64String stringByReplacingOccurrencesOfString:@" " withString:@""];
Easy Peasy, use this line:
NSString *TrimBase64String=[base64String stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
Use below lines of code to create NSString
with Base64 Encoding to avoid white spaces and then post it:
NSString *strbase64 = [YourNSData base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
Check answer here, may be it will help more:
encode image to base64, get a invalid base64 string (ios using base64EncodedStringWithOptions)
I tried many ways and finally found the cause of the problem is the character \r
\r = CR (Carriage Return) // Used as a new line character in Mac OS before X`
[yourBase64String stringByReplacingOccurrencesOfString:@"\r" withString:@""];