cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anthony Ward (JIRA)" <>
Subject [jira] [Created] (CB-13923) method OpenForReadResult returns a -1 length
Date Tue, 27 Feb 2018 12:24:00 GMT
Anthony Ward created CB-13923:

             Summary: method OpenForReadResult returns a -1 length
                 Key: CB-13923
             Project: Apache Cordova
          Issue Type: Bug
          Components: cordova-android
    Affects Versions: cordova-android-7.0.0
         Environment: cordova 8.0.0

cordova-android 7.0.0

cordova-plugin-file 6.0.1
            Reporter: Anthony Ward
            Assignee: Joe Bowser

Here are details to recreate:


In *cordova-android* the -> OpenForReadResult method returns a
-1 length in certain circumstances.

This has a knock on effect to the *cordova-plugin-file* > > readFileAtURL
method, causing file corruption as each chunk effectively has no end.

There is a possible fix in the plugin cordova-plugin-file already proposed


Or I propose it could be fixed upstream in cordova-android here:


In the method OpenForReadResult there is one path (in the catch) that leaves the length as
-1 causing the defect



assetFd = assetManager.openFd(assetPath);

inputStream = assetFd.createInputStream(); length = assetFd.getLength();


catch (FileNotFoundException e)


// Will occur if the file is compressed.

inputStream =;


Adding length = inputStream.available(); in the catch fixes the issue for me, but I'm not
a java developer so can't evaluate if that's a bad idea for another reason.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message