Skip to content

Commit

Permalink
#179 mention the example app in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
plrthink committed Mar 18, 2020
1 parent 34cf4e6 commit c6fffcf
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ import { MainBundlePath, DocumentDirectoryPath } from 'react-native-fs'

> zip source to target
***NOTE: only support zip folder, not file entries***

Example

```js
Expand All @@ -62,15 +64,17 @@ zip(sourcePath, targetPath)
console.log(`zip completed at ${path}`)
})
.catch((error) => {
console.log(error)
console.error(error)
})
```

**`zipWithPassword(source: string, target: string, password: string, encryptionType: string): Promise<string>`**

> zip source to target
*NOTE: encryptionType is not supported on iOS yet, so it would be igonred on that platform.*
***NOTE: only support zip folder, not file entries***

***NOTE: encryptionType is not supported on iOS yet, so it would be igonred on that platform.***

Example

Expand All @@ -85,11 +89,11 @@ zipWithPassword(sourcePath, targetPath, password, encryptionType)
console.log(`zip completed at ${path}`)
})
.catch((error) => {
console.log(error)
console.error(error)
})
```

**unzip(source: string, target: string): Promise**
**`unzip(source: string, target: string): Promise<string>`**

> unzip from source to target
Expand All @@ -107,7 +111,7 @@ unzip(sourcePath, targetPath, charset)
console.log(`unzip completed at ${path}`)
})
.catch((error) => {
console.log(error)
console.error(error)
})
```

Expand All @@ -127,15 +131,15 @@ unzipWithPassword(sourcePath, targetPath, password)
console.log(`unzip completed at ${path}`)
})
.catch((error) => {
console.log(error)
console.error(error)
})
```

**`unzipAssets(assetPath: string, target: string): Promise<string>`**

> unzip file from Android `assets` folder to target path
*Note: Android only.*
***Note: Android only.***

`assetPath` is the relative path to the file inside the pre-bundled assets folder, e.g. `folder/myFile.zip`. ***Do not pass an absolute directory.***

Expand All @@ -144,11 +148,11 @@ const assetPath = './myFile.zip'
const targetPath = DocumentDirectoryPath

unzipAssets(assetPath, targetPath)
.then(() => {
console.log('unzip completed!')
.then((path) => {
console.log(`unzip completed at ${path}`)
})
.catch((error) => {
console.log(error)
console.error(error)
})
```

Expand All @@ -162,14 +166,15 @@ Your callback will be passed an object with the following fields:
- `filePath` (string) the zip file path of zipped or unzipped file.


*Note: Remember to check the filename while processing progress, to be sure that the unzipped or zipped file is the right one, because the event is global.*
***Note: Remember to check the filename while processing progress, to be sure that the unzipped or zipped file is the right one, because the event is global.***

*Note: Remember to unsubscribe! Run .remove() on the object returned by this method.*
***Note: Remember to unsubscribe! Run .remove() on the object returned by this method.***

```js
componentDidMount() {
this.zipProgress = subscribe(({ progress, filePath }) => {
this.setState({ zipProgress: progress })
// the filePath is always empty on iOS for zipping.
console.log(`progress: ${progress}\nprocessed at: ${filePath}`)
})
}

Expand All @@ -179,6 +184,9 @@ componentWillUnmount() {
}
```

## Example App
You can use this repo, https://github.com/plrthink/RNZATestApp, for testing and contribution. For more information please refer to its README.


## Related Projects

Expand Down

0 comments on commit c6fffcf

Please sign in to comment.