GitHub user Beatinu opened a pull request:
https://github.com/apache/cordova-plugin-file/pull/217
CB-13245: (android) Fix bug caused by negative length reported for an asset
<!--
Please make sure the checklist boxes are all checked before submitting the
PR. The checklist
is intended as a quick reference, for complete details please see our
Contributor Guidelines:
http://cordova.apache.org/contribute/contribute_guidelines.html
Thanks!
-->
### Platforms affected
Android
### What does this PR do?
Check the length of CordovaResourceApi.OpenForReadResult in readFileAtURL()
to fix loading Android assets with a length greater than
FileReader.READ_CHUNK_SIZE. When the length returned is < 0, use
InputStream.available() to get the length of compressed assets.
### What testing has been done on this change?
Fixes a bug in one of my apps when loading a large .json file into a string.
### Checklist
- [X] [Reported an issue](http://cordova.apache.org/contribute/issues.html)
in the JIRA database
- [X] Commit message follows the format: "CB-3232: (android) Fix bug with
resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform
affected.
- [ ] Added automated test coverage as appropriate for this change.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/Beatinu/cordova-plugin-file master
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/cordova-plugin-file/pull/217.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #217
----
commit 63fe1b3a91d029f9105be4e55f6fef7ac6392934
Author: Daniel Behnen <[email protected]>
Date: 2017-09-05T17:21:04Z
Use input stream length when input length is negative to fix loading
compressed assets
----
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]