Skip to content

Commit

Permalink
fix(test): Regression when using asset URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
breautek committed Jul 19, 2024
1 parent 6d3deb2 commit f3ffb61
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/android/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1310,10 +1310,20 @@ public CordovaPluginPathHandler getPathHandler() {
}

Uri fileUri = Uri.parse(fileTarget);
String mimeType = null;

try {
CordovaResourceApi.OpenForReadResult resource = resourceApi.openForRead(fileUri);
return new WebResourceResponse(resource.mimeType, null, resource.inputStream);
InputStream io = null;
if (isAssetsFS) {
io = webView.getContext().getAssets().open(fileTarget);
mimeType = getMimeType(fileUri);
} else {
CordovaResourceApi.OpenForReadResult resource = resourceApi.openForRead(fileUri);
io = resource.inputStream;
mimeType = resource.mimeType;
}

return new WebResourceResponse(mimeType, null, io);
} catch (FileNotFoundException e) {
Log.e(LOG_TAG, e.getMessage());
} catch (IOException e) {
Expand Down

0 comments on commit f3ffb61

Please sign in to comment.