* fs.js: forgot one more error refactoring
* Fix path argument in iOS excludeFromBackupKey (#473)
* Fix link to fs.readStream() and to fs.writeStream() and insert link to new function fs.hash()
* Fix the documentation part of https://github.com/wkh237/react-native-fetch-blob/issues/467 "Example code for writeStream ignores that stream.write() returns a promise?"
* More fixes for issue https://github.com/wkh237/react-native-fetch-blob/issues/460 "Error normalization"
IMPORTANT: I wrote the iOS code BLIND (not even syntax highlighting) - this needs to be tested.
- Two or three methods that used callbacks to return results were changed to RN promises
- All methods using promises now use a Unix like code string for the first parameter, e.g. "ENOENT" for "File does not exist" (http://www.alorelang.org/doc/errno.html). The React Native bridge code itself uses this schema: it inserts "EUNSPECIFIED" when the "code" it gets back from Android/iOS code is undefined (null, nil). The RN bridge assigns the code (or "EUNSPECIFIED") to the "code" property of the error object it returns to Javascript, following the node.js example (the "code" property is not part of "standard" Javascript Error objects)
- Important errors like "No such file" are reported (instead of a general error), using the code property.
- I added a few extra error checks that the IDE suggested, mostly for Android (for which I have an IDE), if it seemed important I tried to do the same for teh iOS equivalent function
- I followed IDE suggestions on some of the Java code, like making fields private
- RNFetchBlobFS.java removeSession(): Added reporting of all failures to delete - IS THIS DESIRABLE (or do we not care)?
- readStream: The same schema is used for the emitted events when they are error events
- iOS: added an import for the crypto-digest headers - they are needed for the hash() function submitted in an earlier commit
- Fixed a link in the README.md - unfortunately the anchor-links change whenever even one character of the linked headline in the Wiki page changes
* Fix one issue raised in https://github.com/wkh237/react-native-fetch-blob/issues/477 by using code from https://stackoverflow.com/a/40874952/544779
* fix some access rights, remove unused items
* update gradle version setting in build.gradle
* Revert gradle settings to previous values :-(
* add a missing closing ")"
* Removed the part of an obsolete callback function parameter that I had left in when I converted mkdir to promises (low-level code)
* let mkdir resolve with "undefined" instead of "null" (my mistake)
* mkdir: normalize iOS and Android error if something already exists (file OR folder); return "true" (boolean) on success (failure is rejected promise) - it is not possibel to return "undefined" from a React Native promise from Java
* fix a long/int issue
* my mistake - according to https://facebook.github.io/react-native/docs/native-modules-android.html#argument-types "long" is not possible as argument type of an exported RN native module function
* Adde "utf8" as default encoding for fs.readFile - fixes #450 and #484
* follow my IDEA IDE's recommendations - SparseArray instead of HashMap, and make some fields private
* polyfill/File.js: add a parameter===undefined? check (this happened silently in the test suite)
* make var static again
* Normalized errors for fs.ls()
* forgot one parameter
* more parameter checks
* forgot to resolve the promise
* Forgot ;
* add more error parameter checks
* change readStream()/writeStream() default encoding to utf8 to match the tests in react-native-fetch-blob-dev
* default encoding is set in fs.js (now), no need to do it twice
* ReadStream error events: Set a default error code "EUNSPECIFIED" if no code is returned (should not happen, actually)
* writeFile() Android and iOS: improve errors; ReadStream: Add "ENOENT" (no such file) error event to Android version and add the thus far missing "code" parameter to iOS version
* oops - one "}" too many - removed
* add EISDIR error to readFile()s error vocabulary (iOS and Android)
* "or directory" is misplaced in a "no such file" error message for readFile()
* Android: two reject() calls did not have a code, iOS: slice() did not have code EISDIR, and "could not resolve URI" now is EINVAL everywhere
* writeStream: return ENOENT, EISDIR and EUNSPECIFIED according to the normalized schema (#460); Open a new question about behavior on ENOENT (#491)
* "+ +" was one plus sign too many
* this if has a whole block (that ois why I prefer a style where {} are mandatory even for single-statement blocks)
* I renamed this variable
* 1) #491 "writeStream() does not create file if it doesn't exist?"
2) I had gone overboard with the "@[..]" in the ios code, making some error strings arrays
3) fix typos: rename all ENODIR => ENOTDIR
* Java: getParentFolder() may return null - prevent a NullPointerException by adding one more check
* Relating to #298 -- looping through an array is not supposed to be done with for...in
* Fix IOS syntax errors in #489
* #489 Fix typo and missing return statement
* fix error code
Add ability to cancel android DownloadManager fetches (#502)
This just requires a bit of bookkeeping that keeps track of the task ID to the download manager ID.
Note that the behavior of the download manager remove method is to remove the download and the downloaded file, whether partial or complete.
https://developer.android.com/reference/android/app/DownloadManager.html#remove(long...)
* bump to 0.10.8
* Update PULL_REQUEST_TEMPLATE
* Fix #468 "Messy error returns: Sometimes a string, sometimes an Error object"
* Cleanup: remove an unused constant and duplicate method definitions
* Cleanup:
- fix minor errors in JSDoc comments, for example {string]} => {string}
- fix parameter name "encode" => "encoding" (more logical, and it says so in the function's JSDoc too)
- json-stream.js: split a looooong log message string constant into two parts and fix a typo ("maually"), and the type for objects is "Object" (capitalized) in Flow type annotations
* Fix a (Flow) type conflict - fixes issue #461
* NEEDS REVIEW - Attempt to fix some of issue #460 (Error message normalization)
Error messages reported by iOS and Android versions should be as similar as possible. Also, within the same system there should be consistency. This patch is an attempt to bring a LITTLE more of this consistency to the error messages. I also fixed some very few minor language issues, like "does not exist" (is the correct English). I tried keeping the changes to a minimum.
Background: In my project code I want to know when a file already exists (e.g. after calling fs.createFile), and the only way is to check the error message string that I get. It's bad if they differ between versions (createFileASCII and createFile) and then also between Android and iOS version. At least some core part of the string should be the same, so that I have something to match.
Ideally messages should come from a centralized easy (easier) to maintain file (for both iOS and Android), and ideally both systems should have the same errors and messages as far as possible.
* Fixes https://github.com/wkh237/react-native-fetch-blob/issues/467 by improving the write() function of write streams: By resolving with the RNFetchBlobWriteStream instance instead of with "undefined" writes can now be chained:
RNFetchBlob.fs.writeStream(PATH_TO_FILE, 'utf8', true)
.then((ofstream) => ofstream.write('foo'))
.then((ofstream) => ofstream.write('bar'))
.then((ofstream) => ofstream.write('foobar'))
.then((ofstream) => ofstream.close())
Reference: https://github.com/wkh237/react-native-fetch-blob/issues/467#issuecomment-321194693
* bump to 0.10.8
* Update PULL_REQUEST_TEMPLATE
* Fix #468 "Messy error returns: Sometimes a string, sometimes an Error object"
* Cleanup: remove an unused constant and duplicate method definitions
* Cleanup:
- fix minor errors in JSDoc comments, for example {string]} => {string}
- fix parameter name "encode" => "encoding" (more logical, and it says so in the function's JSDoc too)
- json-stream.js: split a looooong log message string constant into two parts and fix a typo ("maually"), and the type for objects is "Object" (capitalized) in Flow type annotations
* Fix a (Flow) type conflict - fixes issue #461
* NEEDS REVIEW - Attempt to fix some of issue #460 (Error message normalization)
Error messages reported by iOS and Android versions should be as similar as possible. Also, within the same system there should be consistency. This patch is an attempt to bring a LITTLE more of this consistency to the error messages. I also fixed some very few minor language issues, like "does not exist" (is the correct English). I tried keeping the changes to a minimum.
Background: In my project code I want to know when a file already exists (e.g. after calling fs.createFile), and the only way is to check the error message string that I get. It's bad if they differ between versions (createFileASCII and createFile) and then also between Android and iOS version. At least some core part of the string should be the same, so that I have something to match.
Ideally messages should come from a centralized easy (easier) to maintain file (for both iOS and Android), and ideally both systems should have the same errors and messages as far as possible.
Fix Compilation Error in React Native 0.47.0 (#452)
createJSModules was removedin React Native 0.47.0 and results in the attached Build Error.
removing @Override fixes build (didn't remove function because I don't know if it should be kept for downard compatability?)
```
node_modules/react-native-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobPackage.java:23: error: method does not override or implement a method from a supertype
@Override
^
1 error
Incremental compilation of 1 classes completed in 0.219 secs.
:react-native-fetch-blob:compileReleaseJavaWithJavac FAILED
FAILURE: Build failed with an exception.
```