diff --git a/README.md b/README.md index a35b2ce..b9a7e25 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ zip(sourcePath, targetPath) ***NOTE: the string version of source is for folder, the string[] version is for file, so if you want to zip a single file, use zip([file]) instead of zip(file)*** -***NOTE: encryptionType is not supported on iOS yet, so it would be igonred on that platform.*** +***NOTE: On iOS, AES-256 and AES-128 both use AES-256 encryption.*** Example diff --git a/ios/RNZipArchive.m b/ios/RNZipArchive.m index 51e92ba..c4fbeb1 100644 --- a/ios/RNZipArchive.m +++ b/ios/RNZipArchive.m @@ -7,6 +7,7 @@ // #import "RNZipArchive.h" +#import #if __has_include() #import @@ -91,7 +92,8 @@ -(void)stopObserving { if (success) { resolve(destinationPath); } else { - reject(@"unzip_error", @"unable to unzip", error); + NSString *errorMessage = error ? [error localizedDescription] : @"unable to unzip"; + reject(@"unzip_error", errorMessage, error); } } @@ -156,7 +158,8 @@ -(void)stopObserving { BOOL success; [self setProgressHandler]; - success = [SSZipArchive createZipFileAtPath:destinationPath withContentsOfDirectory:from keepParentDirectory:NO withPassword:password andProgressHandler:self.progressHandler]; + BOOL useAES = encryptionType && ![encryptionType isEqualToString:@"STANDARD"]; + success = [SSZipArchive createZipFileAtPath:destinationPath withContentsOfDirectory:from keepParentDirectory:NO compressionLevel:Z_DEFAULT_COMPRESSION password:password AES:useAES progressHandler:self.progressHandler]; self.progress = 1.0; [self zipArchiveProgressEvent:1 total:1]; // force 100% @@ -181,6 +184,7 @@ -(void)stopObserving { BOOL success; [self setProgressHandler]; + // Note: withFilesAtPaths doesn't have AES class method, using password only success = [SSZipArchive createZipFileAtPath:destinationPath withFilesAtPaths:from withPassword:password]; self.progress = 1.0;