Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
YajanaRao authored Nov 11, 2019
1 parent ed2f1b7 commit 3e29b50
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,15 @@ The following constants are available on the `RNFS` export:
- `ExternalDirectoryPath` (`String`) The absolute path to the external files, shared directory (android only)
- `ExternalStorageDirectoryPath` (`String`) The absolute path to the external storage, shared directory (android only)

IMPORTANT: when using `ExternalStorageDirectoryPath` it's necessary to request permissions (on Android) to read and write on the external storage, here an example: [React Native Offical Doc] (https://facebook.github.io/react-native/docs/permissionsandroid)
IMPORTANT: when using `ExternalStorageDirectoryPath` it's necessary to request permissions (on Android) to read and write on the external storage, here an example: [React Native Offical Doc](https://facebook.github.io/react-native/docs/permissionsandroid)

### `readDir(dirpath: string): Promise<ReadDirItem[]>`

Reads the contents of `path`. This must be an absolute path. Use the above path constants to form a usable file path.

The returned promise resolves with an array of objects with the following properties:

```
```js
type ReadDirItem = {
ctime: date; // The creation date of the file (iOS only)
mtime: date; // The last modified date of the file
Expand All @@ -346,7 +346,7 @@ Reads the contents of `dirpath ` in the Android app's assets folder.

The returned promise resolves with an array of objects with the following properties:

```
```js
type ReadDirItem = {
name: string; // The name of the item
path: string; // The absolute path to the item
Expand All @@ -369,7 +369,7 @@ Node.js style version of `readDir` that returns only the names. Note the lowerca
Stats an item at `filepath`. If the `filepath` is linked to a virtual file, for example Android Content URI, the `originalPath` can be used to find the pointed file path.
The promise resolves with an object with the following properties:

```
```js
type StatResult = {
path: // The same as filepath argument
ctime: date; // The creation date of the file
Expand Down Expand Up @@ -510,7 +510,7 @@ Create a directory at `filepath`. Automatically creates parents and does not thr

### `downloadFile(options: DownloadFileOptions): { jobId: number, promise: Promise<DownloadResult> }`

```
```js
type DownloadFileOptions = {
fromUrl: string; // URL to download file from
toFile: string; // Local filesystem path to save the file to
Expand All @@ -528,7 +528,7 @@ type DownloadFileOptions = {
backgroundTimeout?: number // Maximum time (in milliseconds) to download an entire resource (iOS only, useful for timing out background downloads)
};
```
```
```js
type DownloadResult = {
jobId: number; // The download job ID, required if one wishes to cancel the download. See `stopDownload`.
statusCode: number; // The HTTP status code
Expand All @@ -540,7 +540,7 @@ Download file from `options.fromUrl` to `options.toFile`. Will overwrite any pre

If `options.begin` is provided, it will be invoked once upon download starting when headers have been received and passed a single argument with the following properties:

```
```js
type DownloadBeginCallbackResult = {
jobId: number; // The download job ID, required if one wishes to cancel the download. See `stopDownload`.
statusCode: number; // The HTTP status code
Expand All @@ -551,7 +551,7 @@ type DownloadBeginCallbackResult = {

If `options.progress` is provided, it will be invoked continuously and passed a single argument with the following properties:

```
```js
type DownloadProgressCallbackResult = {
jobId: number; // The download job ID, required if one wishes to cancel the download. See `stopDownload`.
contentLength: number; // The total size in bytes of the download resource
Expand Down Expand Up @@ -587,7 +587,7 @@ Check if the the download job with this ID is resumable with `resumeDownload()`.

Example:

```
```js
if (await RNFS.isResumable(jobId) {
RNFS.resumeDownload(jobId)
}
Expand All @@ -603,7 +603,7 @@ Read more about background downloads in the [Background Downloads Tutorial (iOS)

`options` (`Object`) - An object containing named parameters

```
```js
type UploadFileOptions = {
toUrl: string; // URL to upload file to
binaryStreamOnly?: boolean// Allow for binary data stream for file to be uploaded without extra headers, Default is 'false'
Expand All @@ -616,7 +616,7 @@ type UploadFileOptions = {
};

```
```
```js
type UploadResult = {
jobId: number; // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`.
statusCode: number; // The HTTP status code
Expand All @@ -627,7 +627,7 @@ type UploadResult = {

Each file should have the following structure:

```
```js
type UploadFileItem = {
name: string; // Name of the file, if not defined then filename is used
filename: string; // Name of file
Expand All @@ -638,15 +638,15 @@ type UploadFileItem = {

If `options.begin` is provided, it will be invoked once upon upload has begun:

```
```js
type UploadBeginCallbackResult = {
jobId: number; // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`.
};
```

If `options.progress` is provided, it will be invoked continuously and passed a single object with the following properties:

```
```js
type UploadProgressCallbackResult = {
jobId: number; // The upload job ID, required if one wishes to cancel the upload. See `stopUpload`.
totalBytesExpectedToSend: number; // The total number of bytes that will be sent to the server
Expand All @@ -664,7 +664,7 @@ Abort the current upload job with this ID.

Returns an object with the following properties:

```
```js
type FSInfoResult = {
totalSpace: number; // The total amount of storage space on the device (in bytes).
freeSpace: number; // The amount of available storage space on the device (in bytes).
Expand Down Expand Up @@ -696,7 +696,7 @@ Background downloads in iOS require a bit of a setup.

First, in your `AppDelegate.m` file add the following:

```
```js
#import <RNFSManager.h>

...
Expand Down

0 comments on commit 3e29b50

Please sign in to comment.