moberwasserlechner / capacitor-filesharer

Capacitor plugin to download and share files for the Web, Android and iOS! Stop the war in Ukraine!
MIT License
82 stars 20 forks source link

Bug: 23 MB pdf (limit seems to be 10 MB) causes Java error with very little trace info #40

Closed Josje92 closed 1 year ago

Josje92 commented 2 years ago

Capacitor version: 3.0.0

Run npx cap doctor:

πŸ’Š   Capacitor Doctor  πŸ’Š 

Latest Dependencies:

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

Installed Dependencies:

  @capacitor/ios: not installed
  @capacitor/cli: 3.6.0
  @capacitor/core: 3.6.0
  @capacitor/android: 3.6.0

[success] iOS looking great! πŸ‘Œ
[success] Android looking great! πŸ‘Œ

Affected Platform(s):

Current Behavior

App crashes with Java error while trying to open the FileShare popup on a native device or AVD. This is before being able to choose the app to share the file with, the dialog simply won't open. In Android Studio + the web console, the only error that's being shown is as follows: E/Capacitor/Console: File: http://localhost/ - Line 316 - Msg: Error: Java exception was raised during method invocation

There doesn't seem to be more info than this, or it's just me not knowing how to get to that point.

Expected Behavior

The dialog to open.

Reproduction Steps

Try sharing this large PDF while on a device or AVD.

Josje92 commented 2 years ago

Little extra info:

If I simply wipe the contents of the public void share(final PluginCall call) { ... } method, it still won't work with a large base64 string. Same error pops up. It seems that the capacitor-PluginCall class somehow has trouble reading a large base64 string.

I've also tried not encoding the contents, in order to get a smaller string down the line, but it still has the same issue.

Josje92 commented 2 years ago

Made a PR to be able to send a local filepath instead of base64. It seems a large base64 string simply breaks as a capacitor plugin argument. This way, you pass a _capacitor_file_/directory/file-string and have this plugin fetch the contents into the base64 string.

If possible, plz merge or review πŸ™‚

moberwasserlechner commented 1 year ago

PR included in 4.0.0.