php - Must i any pre encode binary data to send it as base64 on ios? -
i send server video (. mov) devide file chunks. every chunk encode base64 , send in http post. php-server decode base64 string standard decoder. size of chunk before send more big, decoded on server. question: must additionally somehow encode binary data before encode base64?
there code:
// ... nsfilehandle* file = [nsfilehandle filehandleforreadingatpath:path]; if( file ) { [file seektofileoffset:[[xdrutils tonumber:[obj valueforkey:@"offset"]] longlongvalue]]; nsdata* data = [file readdataoflength:xkchuncksize]; [file closefile]; nsstring* base64 = [data tobase64string]; [post setobject: base64 forkey: @"record_segment_content"]; } // send server // ... // category base64 en @implementation nsdata (xdrbase64) -(nsstring*)tobase64string { nsstring *string; if ([self respondstoselector:@selector(base64encodedstringwithoptions:)]) { string = [self base64encodedstringwithoptions:kniloptions]; // ios 7+ } else { string = [self base64encoding]; // pre ios7 } return string; } // ... @end
update:
problem solved. on php-server replace space character '+' in base64-string before decode.
Comments
Post a Comment