MohamedRejeb / Calf

Calf is a library that allows you to easily create adaptive UIs and access platform specific APIs with Compose Multiplatform (Adaptive UI, File Picker, WebView, Permissions...).
https://mohamedrejeb.github.io/Calf/
Apache License 2.0
915 stars 41 forks source link

getting this error when uploading pdf #48

Closed rohitkasanwal2708 closed 3 months ago

rohitkasanwal2708 commented 10 months ago

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1020266550, result=-1, data=Intent { dat=content://com.android.providers.downloads.documents/document/raw:/storage/emulated/0/Download/ncert.pdf flg=0x1 }} to activity {xyz.penpencil.unigo/com.myapplication.MainActivity}: java.lang.NumberFormatException: For input string: "raw:/storage/emulated/0/Download/ncert.pdf" at android.app.ActivityThread.deliverResults(ActivityThread.java:5340) at android.app.ActivityThread.handleSendResult(ActivityThread.java:5379) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:67) at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2252) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7842) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) Caused by: java.lang.NumberFormatException: For input string: "raw:/storage/emulated/0/Download/ncert.pdf" at java.lang.Long.parseLong(Long.java:594) at java.lang.Long.valueOf(Long.java:808) at com.mohamedrejeb.calf.picker.URIPathHelper.getPath(UriHelper.kt:30) at com.mohamedrejeb.calf.picker.FilePickerLauncher_androidKt$pickSingleFile$singlePhotoPickerLauncher$1.invoke(FilePickerLauncher.android.kt:138) at com.mohamedrejeb.calf.picker.FilePickerLauncher_androidKt$pickSingleFile$singlePhotoPickerLauncher$1.invoke(FilePickerLauncher.android.kt:135) at androidx.activity.compose.ActivityResultRegistryKt$rememberLauncherForActivityResult$1.invoke$lambda$0(ActivityResultRegistry.kt:106) at androidx.activity.compose.ActivityResultRegistryKt$rememberLauncherForActivityResult$1.$r8$lambda$CrhP0xb3HsgP_dLwJEFAtzTwPms(Unknown Source:0) at androidx.activity.compose.ActivityResultRegistryKt$rememberLauncherForActivityResult$1$$ExternalSyntheticLambda0.onActivityResult(Unknown Source:2) at androidx.activity.result.ActivityResultRegistry.doDispatch(ActivityResultRegistry.java:414) at androidx.activity.result.ActivityResultRegistry.dispatchResult(ActivityResultRegistry.java:371) at androidx.activity.ComponentActivity.onActivityResult(ComponentActivity.java:845) at androidx.fragment.app.FragmentActivity.onActivityResult(FragmentActivity.java:152) at android.app.Activity.dispatchActivityResult(Activity.java:8385) at android.app.ActivityThread.deliverResults(ActivityThread.java:5333)

rohitkasanwal2708 commented 10 months ago

When Im uploading an pdf using the library in android the app is crashing with the above error. showing java.lang.NumberFormatException

im also adding ios build error, in ios app is not crashing but throwing error 2023-12-12 13:42:47.332091+0530 PW Unigo[18379:4737517] [DocumentManager] Failed to associate thumbnails for picked URL file:///Users/rohitchoudhary/Library/Developer/CoreSimulator/Devices/D508FBC1-1417-4169-840B-4563391A65BE/data/Containers/Shared/AppGroup/CE5D31C8-5B84-4F0F-BF54-97EC2CFEE425/File%20Provider%20Storage/ncert.pdf with the Inbox copy file:///Users/rohitchoudhary/Library/Developer/CoreSimulator/Devices/D508FBC1-1417-4169-840B-4563391A65BE/data/Containers/Data/Application/E39CD70A-754F-4EB5-A226-29196C42A4BB/tmp/xyz.penpencil.unigo-Inbox/ncert.pdf: Error Domain=QLThumbnailErrorDomain Code=102 "(null)" UserInfo={NSUnderlyingError=0x600000cb3f30 {Error Domain=GSLibraryErrorDomain Code=3 "Generation not found" UserInfo={NSDescription=Generation not found}}} 2023-12-12 13:42:55.973610+0530 PW Unigo[18379:4737462] [DocumentManager] The view service did terminate with error: Error Domain=_UIViewServiceErrorDomain Code=1 "(null)" UserInfo={Terminated=disconnect method}

rohitkasanwal2708 commented 10 months ago

@MohamedRejeb ^^ these are two error im getting in android and ios I have tested in real device same thing is happening When im uploading image it is working fine

MohamedRejeb commented 7 months ago

Hi, I think that this issue is out of the scope of this library. The main goal for the calf-file-picker is to provide a common way to select files. I'm providing KmpFile which is a wrapper around Uri in android and a wrapper around NSData in iOS. I think it's better to use Uri and NSData to upload large files because KmpFile.readByteArray is not goign to work for large files.

MohamedRejeb commented 3 months ago

Please try again with the latest version, it's working fine for me. Feel free to reopen.