压缩后,我没有得到准确的日志文件

时间:2018-08-03 04:04:49

标签: objective-c email zip logfile

我得到一个日志文件。我正在压缩该文件并通过电子邮件发送。但是,当我解压缩文件并查看内容时,内容完全不同。我认为它是加密格式。也许我采用错误的方法压缩文件并通过电子邮件发送。我使用的是Objective-zip 我不知道该如何通过电子邮件发送。这是我的代码

-(void)mailLogFile {

if ([MFMailComposeViewController canSendMail]) {
    NSDictionary *user = [[DBHelper getSharedInstance] getCurrentUser];
    NSString *propertyQuery = [NSString stringWithFormat:@"SELECT RecentActivityId,PropertyPIC,PropertyId,Message,IsSynced,ActivityTime,ErrorCode,ErrorMessage,ErrorData,EntityId,TableNames From RecentActivity ORDER BY ActivityTime desc"];
    NSArray *resultArry = [[DBHelper getSharedInstance] getRecordsBySQL:propertyQuery];

    NSLog(@"This is the eNVDS in Recent Activity:%@" ,resultArry);
    [[DBHelper getSharedInstance] AddLogFile:[NSString stringWithFormat:@"This is the eNVDS in Recent Activity:%@" ,resultArry]];
    NSPredicate *notsynced = [NSPredicate predicateWithFormat:@"IsSynced == 0 || IsSynced == %@",@"0"];
    NSArray *notsyncedenvds = [resultArry filteredArrayUsingPredicate:notsynced];
    NSLog(@"This is the eNVDS in Recent Activity which is not synced:%@" ,notsyncedenvds);
    [[DBHelper getSharedInstance] AddLogFile:[NSString stringWithFormat:@"This is the eNVDS in Recent Activity which is not synced:%@" ,notsyncedenvds]];


    NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];

    NSString *WritableDBPath= [documentsDirectory stringByAppendingPathComponent:@"Logfile.txt"];

    NSData *data = [NSData dataWithContentsOfFile:WritableDBPath];

    OZZipFile *zipFile32= [[OZZipFile alloc] initWithFileName:WritableDBPath mode:OZZipFileModeCreate legacy32BitMode:YES];
        OZZipWriteStream *stream= [zipFile32 writeFileInZipWithName:@"Logfile.txt" compressionLevel:OZZipCompressionLevelBest];

      [stream writeData:data];
      [stream finishedWriting];



  [zipFile32 close];
    NSString *emailTitle = [NSString stringWithFormat:@"Log file of %@",[NSDate date]];
    NSMutableString *messageBody = [NSMutableString stringWithFormat:@"Login with %@",user[@"Username"]];
    if(![user[@"PropertyName"] isKindOfClass:[NSNull class]])[messageBody appendFormat:@"\n%@",user[@"PropertyName"]];
    [messageBody appendFormat:@"\nApp version : %@",APP_VERSION];
    [messageBody appendFormat:@"\nPlease describe your problem scenario here."];
    [messageBody appendFormat:@"\n\n\nThanks"];

    NSArray *toRecipents = [NSArray arrayWithObject:@"support@aglive.com"];


    MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
    mc.mailComposeDelegate = self;
    [mc setSubject:emailTitle];

    [mc setMessageBody:messageBody isHTML:NO];
    [mc setToRecipients:toRecipents];


    [mc addAttachmentData:data mimeType:@"application/zip" fileName:@"Logfile.zip"];


    [self presentViewController:mc animated:YES completion:nil];

}else{

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Aglive Pro" message:@"You have not configured your mail account. Please configure your mail account from the device settings." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [alert show];
}

}

这是我正在接收的文件的内容-

&Ø›¡íQÇ~ŸEüÒ∞f"ê√0´5CaÙô·O“ÁúZ/ó¿s•#ob!_}K£çx0ô@†‰Ë˙µè@+n |µé†ÇÂ2N—R|¨÷îúîq∞ƒG@0~PºßøÌ@´9Ú[Ä    D˙,Ò≈ÑäXπs˝#èõv30¸w‹
Ü;ùÓ* Ëè&à§∑T—0ô⁄˚ñB;u–˙$Í·/Q¡Yø#EHØ4™lø§äïtV>^=º[¸UgDG…Cnf¢ì˚†y¢ÍÙÿQX1¬˚çı±€·≥•ÉütÙ«—ïã@"\oKïÊ›:ÀÂ\œ˘"a]≤-o÷<Z‹ôù¸9%OœU∂˘3ëzsfl‹ı‰sHÉG£ZfiY*•¶°âu¶€&“î—]ÛȬ∂Òa5˚⁄Ω>›_˙˝˙Å˙¬È•)J£497∞◊ÊzˇyvÂ>;ե뙣fiF9˙ŪVÕUeö§ôVfÇo^¡8µs=4¿É‹SyUæó\ÉG
‚›ıëcÆÀflE^ır^m€7ı™oX)£@§Æ6⁄{öá◊|–≈flç“Ú$6È`lP..*;•∂»b2S∑6‘Ènd(7◊E$ù‘%|o:¯’_#am   kt◊ÁÎ4Øp4,Ù\W*[K1…oπ3óŒ`ìó͆斣i'O4`62 ce«9‹∂À03¶«fl?^)€D√7ˆœ–u˚º{kÓÆ»±R°ß{∏<G[7‘ék⁄∂‘6¯ªútL,rj˘É™„BÑ:∞†vÒ¡÷Eo◊pC%ìÄà3·m¨(R^¢R~Ø«æ†∏XÑZˇ)∆úz˘*≤P•g‡¸c≈1± ÈüÂv'≈Cöï§ï.ù‰pm∆)•|WGıË^†u∆éW›ß„å˜{xˆ_Hov5à°TAmªÒO∫1ÅGXiÈ.W-∞.F$≤p˚È˘8QOË}/œŒL
KW%y@&ZânH;ÀE:îaWÅÜk®Ë”‘ÆöfJÉ$≠Ê≈⁄ì>^ÍÃ_U¶>†èêé:-˛$"xfi@¥A⁄1∂„äWæƒø˜™Õ†ùRR®≤•(4ø Á•˘S7≤≥«FvígîK¨≠ˇ%C‚<KÓÙTXã≈⁄N˝tåcS’◊2†:i¨ŒªËØ˚DႡ*Œ0Á•B   £-ígM8 ÁÇ')£çÑ€© ∂&¥Ú¬á◊-µ‰‘b?˝\} V Ë±d’µƒ2;è3ÀÈõ‘®ïQjAõ˛´’ÛeZÊ3.Nuü‚∫|ÂìZ"ëZ∏«
˙˛Æ.`Ææm¶ù"€î◊√D·‘fiAÉ}[≠≈0{e§o≈î    ’∫:uUDŸ|(ïÉ¥€”]ͨÙ2¨6≥√√õôÿY ñ=rvƧ9;ïOuÄ2SÄ9É8îi∆“?=´Ó[;<Èeåë¡`uwÿ’û8®wí8Ë«©‰LËj√_ Ωú¯/nÚb”£¸i|l÷©íë%7é‡dE≠Z…ûÌÿ?õ◊‘LÂNëC\W(fOãú◊ªfl.]Yö"…ÌAfl&ı„ß3D*{ÂÆH•ÛÊ˙ø«˘≠    ¶Ø™öåÔÆM.◊ßÎpê@KÀÂÜŸÑß;~EH‹Ìâ{$ üêXìsnãñ%∫
Ÿ!ç<ï 'EÉq«:ñ¶∞∏ÿâ:` 6]Úãã©„_"›iefB%«1”Jê˛ÄÜœ4«]bÂ}õÁh_«ë«é!‡´“fi∏mîs„R!¸ÁñT˙⁄«*s=∏œ˘Ä•5ç7Gàn"èÊ¿À⁄∂ñuSx25¶eâõººY˛B1
TÌxùÚ‹Y+08∆_(|JAfiñ{Y∏¯˛*‹‹Á˝ÖóssZœ0„Ñeπ[≠F‚¥ø[«õˇ©à0ıåHôbÉS $˝‚¯Äù‰b

解压缩后,我应该获得正确的日志文件。我知道我必须对此代码进行更改

[mc addAttachmentData:data mimeType:@"application/zip" fileName:@"Logfile.zip"];

因为在这里我发送的数据和以前一样,但是我无法发送zipFile32。如何从这里继续?

0 个答案:

没有答案