Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions ios/RNZipArchive.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import "RNZipArchive.h"
#import <zlib.h>

#if __has_include(<React/RCTEventDispatcher.h>)
#import <React/RCTEventDispatcher.h>
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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%
Expand All @@ -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;
Expand Down