Giter VIP home page Giter VIP logo

react-native-fetch-blob-dev's Introduction

react-native-fetch-blob dev environment

This repository is for developers who interested in modifying and improving react-native-fetch-blob.

Feature branch v0.11.0

Bug fix branch v0.10.9

prerequisites

  • node.js > 5.1.0
  • A valid Dropbox API token
  • [rnpm](npm unlink) react native package manager

clone the repository

This repository use git submodule, for first time clone

$ git clone --recursive -j8 https://github.com/wkh237/react-native-fetch-blob-dev.git

update submodules

$ git submodule update --init --recursive

run and install test app

Before install the test app, you should replace constants DROPBOX_TOKEN and TEST_SERVER_URL in src/test/tests.js

// replace this with your machine's IP, it can be "localhost:8123" when using simulator
+ const TEST_SERVER_URL = 'http://192.168.0.14:8123'                                                                                     
// replace this with your dropbox token
+ const DROPBOX_TOKEN = 'fsXcpmKPrHgAAAAAAAAAoXZhcXYWdgLpQMan6Tb_bzJ237DXhgQSev12hA-gUXt4'                                          

To generate test app template, simply execute npm test <platform> command from root folder.

$ npm test ios
# or
$ npm test android

The script will initialize a new RN app named RNFetchBlobTest (right in the project's /RNFetchBlobTest folder), it will also launch the test app by the platform given, and a nodejs server for test. You only need to run this script once.

dev server

There is a test server for sending and receiving requests from test app, also it watches files in several directories and copy changed files to test app's folder.

To install dev server modules, execute the following command from root folder

$ npm install 

To start dev server, go test-server folder and execute

$ node server

work on android native code

After the test app installed, change settings.gradle in RNFetchBlobTest/android/

rootProject.name = 'RNFetchBlobTest'

include ':app'
include ':react-native-fetch-blob'
// change this line so that the fetch-blob module in test app points to android project in src folder
- project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android')                         
+ project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../../src/android')                         

Now open the android project in RNFetchBlobTest/android folder with you IDE, every changes you made to react-native-fetch-blob project will directly maps to src folder.

Always keep in mind, once you changed native code you have to recompile it otherwise it uses the same native executables.

work on ios native code

After the test app installed, open the .xcodeproj file inside RNFetchBlobTest/ios with XCode.

Delete existed RNFetchBlob.xcodeproj in RNFetchBlobTest -> Libraries since this one is the one in RNFetchBlobTest/node_modules/react-native-fetch-blob/ios/ we're going to change its reference to src/ios/RNFetchBlob.xcodeproj.

Right click on Libraries select add new files to "RNFetchBlobTest.xcodeproj" .. and select src/ios/RNFetchBlob.xcodeproj. Now every changes you made to RNFetchBlob project will directly maps to the one in src folder.

Also, you have to add CameraRoll to the RNFetchBlobTest project otherwise the test case will crash the app.

Always keep in mind, once you changed native code you have to recompile it otherwise it uses the same native executables.

react-native-fetch-blob-dev's People

Contributors

bcpclone avatar lll000111 avatar wkh237 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

react-native-fetch-blob-dev's Issues

Which tests are available?

I just checked if the tests are even relevant to my changes - since I concentrated on filesystem access, I don't care about the download code.

Looking inside test/test-init.js I see that the only test that is "on" is an include for require('./test-0.10.7').

Do I simply enable the other ones? Are the tests version-specific (see above require and all the other per-version tests)? What does that mean for the current tests?

Test status

I ran them all on my current code (https://github.com/lll000111/react-native-fetch-blob/tree/0.10.9) and this is the result. I don't think any of those errors are related to anything I did.

Failing tests (unlikely to be related to my changes)

test-0.5.1

  • remove() should work correctly
  • dispose() should work correctly

test-0.7.0

  • "task not canceled" (at the very end)

test-0.9.0

  • cache control header and range request test => combined file size check
  • #73 unicode response BASE64 content test => but on screen "expect" and "actual" strings look exactly equal...???
  • request should not retry after timed out

test-0.10.0

  • cookie test: TypeError: undefined is not an object (evaluating '_reactNativeFetchBlob2.default.net.getCookies')`
  • #171 verification (timeout)

test-0.10.1

  • Invalid promise.resolve call after task is canceled #176
  • the rest after the above is skipped

test-0.10.5

  • #296 Android Download Manager should not crash the app when status code is not 200:

test-0.10.7

  • HTTPS request should be cancellable when fileCache or path is set
    UPDATE: Today (repeat testing for new commits) this test frags my emulator - I have to "wipe data", Re-installation and restart is not enough)

test-background

  • background http response (timeout)

test-firebase

9 of 10 pass

  • Image underneath "download to base64" is not shown (remains gray)
  • upload from CameraRoll Error: Download manager could not resolve downloaded file path.`

test-android

5 of 7 pass
2 x Error: Download manager could not resolve downloaded file path.`

Get message open failed: EPERM (Operation not permitted) on Android 11 API 30

Hi everyone! after update phone to android 11 apps stop generating a CSV file on external storage using pathToWrite = ${RNFetchBlob.fs.dirs.SDCardDir}/Control.csv;. Before the update its working fine. Now I'm getting message "open failed: EPERM (Operation not permitted)".

Please help me to solve this issue. Thanks!

system and libraries information...
System:
OS: Windows 10 10.0.19042
CPU: (8) x64 Intel(R) Core(TM) i7-4700MQ CPU @ 2.40GHz
Memory: 3.33 GB / 15.94 GB
Binaries:
Node: 12.13.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.12.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 4.6.1 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 18, 23, 24, 25, 26, 27, 28, 29, 30, 31
Build Tools: 23.0.1, 25.0.1, 26.0.1, 27.0.3, 28.0.3, 29.0.0, 29.0.2, 30.0.2
System Images: android-24 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
Android NDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: Version 4.2.0.0 AI-202.7660.26.42.7486908
Visual Studio: 16.7.30621.155 (Visual Studio Community 2019)
Languages:
Java: 1.8.0_111
Python: 3.5.0
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.63.2 => 0.63.2
react-native-windows: Not Found
npmGlobalPackages:
react-native: Not Found

"node server": endless loop copying files

EDITED:

Since my problems have changed throughout the experiments - to have a starting point I tried to install everything as-is and run it but that leads to many errors.

BUILD error description removed, using my own code and updating the image picker as described in the next comment got rid of that.

When I try to run node server I get

fs.js:652
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: EPERM: operation not permitted, open 'D:\Documents\Projects\react-native-fetch-blob-dev\src\.git'
    at Object.fs.openSync (fs.js:652:18)
    at Object.fs.writeFileSync (fs.js:1299:33)
    at D:\Documents\Projects\react-native-fetch-blob-dev\test-server\server.js:300:12
    at D:\Documents\Projects\react-native-fetch-blob-dev\node_modules\mkdirp\index.js:48:26
    at FSReqWrap.oncomplete (fs.js:153:5)

This is an impossible error, I'm doing everything as the same user and I have full permissions for that file:

$ ls -l /d/Documents/Projects/react-native-fetch-blob-dev/src/.git
-rw-r--r-- 1 mha 197609 28 Aug 14 12:57 /d/Documents/Projects/react-native-fetch-blob-dev/src/.git

mha@mha-MAINPC MINGW64 /D/Documents/Projects/react-native-fetch-blob-dev/test-server (master)
$ cat /d/Documents/Projects/react-native-fetch-blob-dev/src/.git
gitdir: ../.git/modules/src

When I put a console.log(111111, targetPath, path) in front of the error-causing line I get

'..\\src\\.git' '..\\src\\.git'

But all calls are of this pattern (not that I understand why the code copies files onto themselves?) but only that one causes that message. For example, the first one with the two variable values '..\\test\\.flowconfig' '..\\test\\.flowconfig' worked just fine...

EDIT: When I use my own repo this same problem appears at a different point:

file changed ..\src\.git\hooks\update.sample
fs.js:652
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: EPERM: operation not permitted, open 'D:\Documents\Projects\react-native-fetch-blob-dev\src\.git\objects\pack\pack-5a17f2a83dd647dbf3bacaa904c799a4ec54f500.idx'

I have no idea what to do. I'm running out of ideas, options and time. I don't think there should be much wrong with my patch(es) over at https://github.com/lll000111/react-native-fetch-blob/tree/0.10.9, but I just can't run those tests.

By the way, what is missing from the instructions is how to use my own folk of the repo. I can just manually clone it to ./src/, but I don't want to learn how to manipulate the git submodule stuff you already setup. I guess I can just ignore it apart from the initial install, I think don't need git any more for this test-dev repo?

Q: The code in Android studio

When I open the (thus far unchanged) ./src/android/ code in Android studio I already get numerous errors: https://gist.github.com/lll000111/423b858d707daf5eba5212ca5e1f6baa

Shouldn't the project be error-free when I use that IDE?

If not, what do I have to do to make it error-free? Shouldn't I be able to build it in Android Studio?

If not, what IDE and environment are you using for development?


Thanks!

Which tests should actually work?

I don't think those tests actually all work as they should, independent of any of my changes.

Many of the tests fail, but those are tests for things that my edits didn't touch. I concentrated on a few filesystem related things only.

Here's a hilarious example, test-stream.js only is enabled:

image


The test is actually still running (-13,000% and counting now), the server still shows "write data " messages.


test-0.10.7 and test-background.js don't work either. The "fs" tests are at 100% - the only ones that I care about.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.