20170329 Base64 与 暴风_点播上传接口处理

暴风 上传第一步

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 *  @"{\n  \"uptype\" : 0,\n  \"filesize\" : 12489665,\n  \"filetype\" : 0,\n  \"filekey\" : \"tom\",\n  \"deadline\" : 1479874368,\n  \"callbackurl\" : \"http:\\/\\/mycompany.com\",\n  \"filename\" : \"test.mp4\",\n  \"servicetype\" : 1\n}"   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];

结果:
baseStr __NSCFString * @"eyJ1cHR5cGUiOjAsInNlcnZpY2V0eXBlIjoxLCJmaWxlbmFtZSI6InRlc3QubXA0\r\nIiwiZmlsZWtleSI6InRvbSIsICJmaWxlc2l6ZSI6MTI0ODk2NjUsImZpbGV0eXBl\r\nIjowLCJkZWFkbGluZSI6MTQ1MTQ5MTIwMCwgImNhbGxiYWNrdXJsIjoiaHR0cDov\r\nL215Y29tcGFueS5jb20ifQ==" 0x000060000025ab20

你可能感兴趣的:(20170329 Base64 与 暴风_点播上传接口处理)