Skip to content

Commit

Permalink
feat: update format
Browse files Browse the repository at this point in the history
  • Loading branch information
hanpanpan200 committed Feb 8, 2017
1 parent dda1385 commit a32ed6c
Showing 1 changed file with 39 additions and 37 deletions.
76 changes: 39 additions & 37 deletions README.md
Expand Up @@ -38,9 +38,9 @@ Share Social , Sending Simple Data to Other Apps
```
4. Insert the following lines inside the dependencies block in `android/app/build.gradle`:

```
compile project(':react-native-share')
```
```
compile project(':react-native-share')
```

#### Windows
[Read it! :D](https://github.com/ReactWindows/react-native)
Expand Down Expand Up @@ -94,40 +94,6 @@ Supported options:

***NOTE: If both `message` and `url` are provided `url` will be concatenated to the end of `message` to form the body of the message. If only one is provided it will be used***

#### Url format when sharing a file

##### Share base 64 file

When share a base 64 file, please follow the format below:

```
url: "data:<data_type>/<file_extension>;base64,<base64_data>"
```
For example, when share a base 64 `mp3` file, the `url` should be:

```
url: "data:audio/mp3;base64,<base64_data>"
```

When share a base 64 image file with `png` file extension, the `url` should be:

```
url: "data:image/png;base64,<base64_data>"
```

##### Share file directly

When share a local file directly, please follow the format below:

```
url: "file://<file_path>",
```

For example, when share a `pdf` file from: `/storage/emulated/0/demo/test.pdf`, the `url` should be:

```
url: "file:///storage/emulated/0/demo/test.pdf"
```

## how it looks:

Expand All @@ -138,6 +104,7 @@ url: "file:///storage/emulated/0/demo/test.pdf"

## Usage

### Example code
```javascript
import React, { Component } from 'react';
import {
Expand Down Expand Up @@ -323,3 +290,38 @@ const REACT_ICON = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAA

AppRegistry.registerComponent('TestShare', () => TestShare);
```

### Url format when sharing a file

#### Share base 64 file

When share a base 64 file, please follow the format below:

```
url: "data:<data_type>/<file_extension>;base64,<base64_data>"
```
For example, when share a base 64 `mp3` file, the `url` should be:

```
url: "data:audio/mp3;base64,<base64_data>"
```

When share a base 64 image file with `png` file extension, the `url` should be:

```
url: "data:image/png;base64,<base64_data>"
```

#### Share file directly

When share a local file directly, please follow the format below:

```
url: "file://<file_path>",
```

For example, when share a `pdf` file from: `/storage/emulated/0/demo/test.pdf`, the `url` should be:

```
url: "file:///storage/emulated/0/demo/test.pdf"
```

0 comments on commit a32ed6c

Please sign in to comment.