Skip to content

Commit

Permalink
feat: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
reime005 committed Jan 3, 2020
1 parent d324a5a commit d210b00
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 164 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ Is there an example/sandbox app to test out this package?

> Yes, there is a simple react native app that comes with an [express](https://github.com/expressjs/express) server where you can see react-native-background-upload in action and try things out in an isolated local environment.

[ReactNativeBackgroundUploadExample](https://github.com/Vydia/ReactNativeBackgroundUploadExample)
[RNBackgroundExample](https://github.com/Vydia/react-native-background-upload/blob/master/example/RNBackgroundExample)

Does it support iOS camera roll assets?

Expand Down
2 changes: 1 addition & 1 deletion example/RNBackgroundExample/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ const App: () => React$Node = () => {
<Button
title="Tap To Upload Multipart"
onPress={() => onPressUpload({
url: `http://${Platform.OS === 'ios' ? 'localhost' : '10.0.2.2'}:3000/upload_multipart`,
url: `http://${Platform.OS === 'ios' ? 'localhost' : '10.0.2.2'}:8080/upload_multipart`,
field: 'uploaded_media',
type: 'multipart'
})}
Expand Down
50 changes: 50 additions & 0 deletions example/RNBackgroundExample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Example App for [react-native-background-upload](https://github.com/Vydia/react-native-background-upload)

This is a React Native app and Express server that servers ars a very basic
implementation of react-native-background-upload. Use this repo to experiment
with the package, or fork this repo and use it to create a minimal reproduction
of a bug or other issue when opening up a github issue on
[react-native-background-upload](https://github.com/Vydia/react-native-background-upload).

## Usage

1. Clone the repo
1. `yarn install`
1. `yarn server`
1. Run the example app `react-native run-ios` or `react-native run-android`
1. Tap the button in the mobile app to perform an upload.

If you are running on an Android enumlator/device and uploads don't 'just work', run `adb reverse tcp:3000 tcp:3000` after `react-native run-android`. This will allow the device to communicate with the server. Otherwise it won't work.

## E2E Tests

You need to have [Detox setup](https://github.com/wix/Detox/blob/master/docs/Introduction.GettingStarted.md).

To run the E2E Tests for Android, do the following:

1. Clone the repo
1. `yarn`
1. `yarn deploy/release/android`
1. `yarn e2e/test/android`

To run the E2E Tests for iOS, do the following:

1. Clone the repo
1. `yarn`
1. `yarn deploy/release/ios`
1. `yarn e2e/test/ios`

## Important files to look at

### [App.js](https://github.com/Vydia/react-native-background-upload/blob/master/example/RNBackgroundExample/App.js)

The React Native component that allows the user to choose an image from device
and upload it to the localhost server.

*Note: In the iOS simulator, you can add images and videos to the camera roll by
dragging and dropping files from finder onto the simulator window. In the Android
emulator you can usually use the emulator camera app to take test picture.*

### [e2e/start-server.js](https://github.com/Vydia/react-native-background-upload/blob/master/example/RNBackgroundExample/e2e/start-server.js)

The express server that receives the upload and writes it to file.
161 changes: 0 additions & 161 deletions example/RNBackgroundExample/Upload.js

This file was deleted.

2 changes: 1 addition & 1 deletion example/RNBackgroundExample/e2e/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const startTestServer = () => {
const multer = require('multer')
const upload = multer({ dest: 'tmp/multipart/' })

const helloMessage = 'Hi! The server is listening on port 3000. Use the React Native app to start an upload.'
const helloMessage = 'Hi! The server is listening on port 8080. Use the React Native app to start an upload.'

app.get('/', function (req, res) {
res.send(helloMessage)
Expand Down
1 change: 1 addition & 0 deletions example/RNBackgroundExample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.1",
"private": true,
"scripts": {
"server": "node e2e/start-server.js",
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
Expand Down

0 comments on commit d210b00

Please sign in to comment.