capacitor-plugins icon indicating copy to clipboard operation
capacitor-plugins copied to clipboard

Filesystem.copy not working con content:/ android

Open massimoliani opened this issue 1 year ago • 0 comments

Bug Report

Plugin(s)

Filesystem copy function

Capacitor Version

Latest Dependencies:

@capacitor/cli: 6.0.0 @capacitor/core: 6.0.0 @capacitor/android: 6.0.0 @capacitor/ios: 6.0.0

Installed Dependencies:

@capacitor/cli: 5.7.4 @capacitor/core: 5.7.4 @capacitor/android: 5.7.4 @capacitor/ios: 5.7.4

Platform(s)

Android

Current Behavior

I'm trying to copy a video or picture file selected with @capawesome/capacitor-file-picker the returned path is in the form content:/....provider..../name.... When starting the copy I got an error from bridge that let the android app crash immediately.

Expected Behavior

I expect the video file can be copied to local app folder like documents or data.

Code Reproduction

Using file picker you can pick a video file from the gallery and try to copy it to app documents.

Other Technical Details

I test it on API30 and API33 but the result is the same.

Additional Context

This is the error and exception letting the app to crash: 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:800) at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0) at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference at com.capacitorjs.plugins.filesystem.Filesystem.getDirectory(Filesystem.java:203) at com.capacitorjs.plugins.filesystem.Filesystem.getFileObject(Filesystem.java:227) at com.capacitorjs.plugins.filesystem.Filesystem.copy(Filesystem.java:109) at com.capacitorjs.plugins.filesystem.FilesystemPlugin._copy(FilesystemPlugin.java:430) at com.capacitorjs.plugins.filesystem.FilesystemPlugin.copy(FilesystemPlugin.java:381) 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:800)  at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0)  at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8)  at android.os.Handler.handleCallback(Handler.java:938)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:223)  at android.os.HandlerThread.run(HandlerThread.java:67)  2024-04-18 22:57:35.221 21631-21924 AndroidRuntime it.skirankapp.official E FATAL EXCEPTION: CapacitorPlugins Process: it.skirankapp.official, PID: 21631 java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:809) at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0) at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: 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:800) at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0)  at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8)  at android.os.Handler.handleCallback(Handler.java:938)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:223)  at android.os.HandlerThread.run(HandlerThread.java:67)  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference at com.capacitorjs.plugins.filesystem.Filesystem.getDirectory(Filesystem.java:203) at com.capacitorjs.plugins.filesystem.Filesystem.getFileObject(Filesystem.java:227) at com.capacitorjs.plugins.filesystem.Filesystem.copy(Filesystem.java:109) at com.capacitorjs.plugins.filesystem.FilesystemPlugin._copy(FilesystemPlugin.java:430) at com.capacitorjs.plugins.filesystem.FilesystemPlugin.copy(FilesystemPlugin.java:381) 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:800)  at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0)  at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8)  at android.os.Handler.handleCallback(Handler.java:938)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:223)  at android.os.HandlerThread.run(HandlerThread.java:67) 

Thank you very much

massimoliani avatar Apr 18 '24 21:04 massimoliani