Fixed file transfer in chat if file was picked from generic file picker

This commit is contained in:
Sylvain Berfini 2024-12-19 16:56:10 +01:00
parent 2c9a15a007
commit 8f52182959
2 changed files with 10 additions and 4 deletions

View file

@ -153,9 +153,15 @@ open class ConversationFragment : SlidingPaneChildFragment() {
) { files ->
sendMessageViewModel.closeFilePickerBottomSheet()
for (fileUri in files) {
val path = fileUri.toString()
Log.i("$TAG Picked file [$path]")
sendMessageViewModel.addAttachment(path)
lifecycleScope.launch {
val path = FileUtils.getFilePath(requireContext(), fileUri, false).orEmpty()
if (path.isNotEmpty()) {
Log.i("$TAG Picked file [$path]")
sendMessageViewModel.addAttachment(path)
} else {
Log.e("$TAG Failed to pick file [$fileUri]")
}
}
}
}

View file

@ -206,7 +206,7 @@ class FileUtils {
Log.e(
"$TAG Couldn't get URI for file [$file] using file provider ${context.getString(
R.string.file_provider
)}"
)}: $e"
)
Uri.parse(path)
}