You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[error] Xcode is not installed
[success] Android looking great! 👌
Other API Details
No response
Platforms Affected
iOS
Android
Web
Current Behavior
Relevant web layer code:
constimageName="image.jpg";constfileContent=awaitfetch(`/assets/${imageName}`);constblob=awaitfileContent.blob();constbase64Data=(awaitconvertBlobToBase64(blob))asstring;// Write the file to cache directoryconstsavedFile=awaitFilesystem.writeFile({path: imageName,data: base64Data,directory: Directory.Cache,});
When file is found and it forms a proper base64Data, the application works as expected. However, when I mistyped the fetch path to /public/assets/${imageName}, the file was not found and therefore base64Data formed was empty like so: data:image/jpeg;base64,, this causes Filesystem.writeFile to crash the application:
23:01:27.588 E Unable to open asset URL: http://localhost/public/assets/image.jpg
23:01:27.611 V To native (Capacitor plugin): callbackId: 109817524, pluginId: Filesystem, methodName: writeFile
23:01:27.611 V callback: 109817524, pluginId: Filesystem, methodName: writeFile, methodData: {"path":"image.jpg","data":"data:image/jpeg;base64,","directory":"CACHE"}
23:01:27.612 E Serious error executing plugin
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:138)
at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:821)
braincomb
changed the title
[Bug]: Filesystem.writeFile throws java.lang.ArrayIndexOutOfBoundsException when file is not found
[Bug]: Filesystem.writeFile throws java.lang.ArrayIndexOutOfBoundsException when base64Data passed is empty
Oct 23, 2024
This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed.
Please see the Contributing Guide for how to create a Sample App.
Thanks! Ionitron 💙
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.
Capacitor Version
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 6.1.2
@capacitor/core: 6.1.2
@capacitor/android: 6.1.2
@capacitor/ios: 6.1.2
Installed Dependencies:
@capacitor/cli: 6.1.2
@capacitor/core: 6.1.2
@capacitor/android: 6.1.2
@capacitor/ios: 6.1.2
[error] Xcode is not installed
[success] Android looking great! 👌
Other API Details
No response
Platforms Affected
Current Behavior
Relevant web layer code:
When file is found and it forms a proper
base64Data
, the application works as expected. However, when I mistyped the fetch path to/public/assets/${imageName}
, the file was not found and thereforebase64Data
formed was empty like so:data:image/jpeg;base64,
, this causes Filesystem.writeFile to crash the application:Full stacktrace attached:
stacktrace.txt
Expected Behavior
When base64Data passed is empty, I expect the application to not crash and simply return and propagate the error to the web layer.
Project Reproduction
N/A
Additional Information
No response
The text was updated successfully, but these errors were encountered: