Skip to content

Commit

Permalink
list the way to works with expo in the doc
Browse files Browse the repository at this point in the history
  • Loading branch information
plrthink committed Aug 9, 2024
1 parent 9ec0811 commit 9c36c55
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Zip archive utility for react-native

In order to comply with the new privacy policy of the App Store on iOS, you need to upgrade react-native-zip-archive to version 7.0.0, which requires the deployment target to be iOS 15.5 or later.

## For Expo Users

The only way to make this work with Expo is to create a [dev build](https://docs.expo.dev/workflow/overview/#development-builds), the expo go is not supported.

## Compatibility

| react-native version | react-native-zip-archive version |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ public void getUncompressedSize(String zipFilePath, String charset, final Promis
long totalSize = getUncompressedSize(zipFilePath, charset);
promise.resolve((double) totalSize);
}

/**
* Return the uncompressed size of the ZipFile (only works for files on disk, not in assets)
*
Expand Down
21 changes: 17 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ const normalizeFilePath = (path) =>
path.startsWith("file://") ? path.slice(7) : path;

export const unzip = (source, target, charset = "UTF-8") => {
return RNZipArchive.unzip(normalizeFilePath(source), normalizeFilePath(target), charset);
return RNZipArchive.unzip(
normalizeFilePath(source),
normalizeFilePath(target),
charset
);
};
export const isPasswordProtected = (source) => {
return RNZipArchive.isPasswordProtected(normalizeFilePath(source)).then(
Expand Down Expand Up @@ -49,16 +53,25 @@ export const zipWithPassword = (

export const zip = (source, target) => {
return Array.isArray(source)
? RNZipArchive.zipFiles(source.map(normalizeFilePath), normalizeFilePath(target))
: RNZipArchive.zipFolder(normalizeFilePath(source), normalizeFilePath(target));
? RNZipArchive.zipFiles(
source.map(normalizeFilePath),
normalizeFilePath(target)
)
: RNZipArchive.zipFolder(
normalizeFilePath(source),
normalizeFilePath(target)
);
};

export const unzipAssets = (source, target) => {
if (!RNZipArchive.unzipAssets) {
throw new Error("unzipAssets not supported on this platform");
}

return RNZipArchive.unzipAssets(normalizeFilePath(source), normalizeFilePath(target));
return RNZipArchive.unzipAssets(
normalizeFilePath(source),
normalizeFilePath(target)
);
};

export const subscribe = (callback) => {
Expand Down

0 comments on commit 9c36c55

Please sign in to comment.