20170329 Base64와 폭풍팟캐스트 업로드 인터페이스 처리

2173 단어
폭풍 업로드 첫걸음
JSON (사전) 에서 NSString 으로 전환하고, 서열화되고, 전의 문자가 있으며,base64 인코딩
//          JSON  ,  JSON    , :
    NSDictionary * dataDict = @{@"uptype":@0,@"servicetype":@1,@"filename":@"test.mp4",@"filekey":@"tom",@"filesize":@12489665,@"filetype":@0,@"deadline":@1451491200,@"callbackurl":@"http://mycompany.com" };
NSError *parseError = nil;
    
    NSData  *jsonData = [NSJSONSerialization dataWithJSONObject:dataDict
                         
                                                        options:NSJSONWritingPrettyPrinted
                         
                                                          error:&parseError];

NSString * sttt = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

>     
> sttt  __NSCFString *  @"{
\"uptype\" : 0,
\"filesize\" : 12489665,
\"filetype\" : 0,
\"filekey\" : \"tom\",
\"deadline\" : 1479874368,
\"callbackurl\" : \"http:\\/\\/mycompany.com\",
\"filename\" : \"test.mp4\",
\"servicetype\" : 1
}" 0x00006000001b5b60 NSString * baseStr = [[sttt dataUsingEncoding: NSUTF8StringEncoding] base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];

 
NSString * strrrrr = @"{"uptype":0,"servicetype":1,"filename":"test.mp4","filekey":"tom", "filesize":12489665,"filetype":0,"deadline":1451491200, "callbackurl":"http://mycompany.com"}";//안드로이드한테 받으러 왔어요.
NSString * baseStr = [[strrrrr dataUsingEncoding: NSUTF8StringEncoding] base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
결과: baseStrNSCFString * @"eyJ1cHR5cGUiOjAsInNlcnZpY2V0eXBlIjoxLCJmaWxlbmFtZSI6InRlc3QubXA0\rIiwiZmlsZWtleSI6InRvbSIsICJmaWxlc2l6ZSI6MTI0ODk2NjUsImZpbGV0eXBl\rIjowLCJkZWFkbGluZSI6MTQ1MTQ5MTIwMCwgImNhbGxiYWNrdXJsIjoiaHR0cDov\rL215Y29tcGFueS5jb20ifQ=="0x000060000025ab20

좋은 웹페이지 즐겨찾기