Skip to content

Return correct paths in files saves#3

Open
supra08 wants to merge 1 commit intomasterfrom
fix-android-savefile-path-dashwave
Open

Return correct paths in files saves#3
supra08 wants to merge 1 commit intomasterfrom
fix-android-savefile-path-dashwave

Conversation

@supra08
Copy link

@supra08 supra08 commented Aug 28, 2025

Important

Fixes file path retrieval in FilePickerDelegate.kt by using FileUtils.getFullPathFromTreeUri() to handle content URIs correctly.

  • Behavior:
    • In FilePickerDelegate.kt, saveFile() now uses FileUtils.getFullPathFromTreeUri() to get the correct file path from a URI, instead of using uri.path.
    • Handles content URIs to ensure the actual file path is returned, not just a path in the Downloads folder.
  • FileUtils:
    • Adds logic in getFullPathFromTreeUri() to handle content URIs by querying the content resolver for the actual file path.
    • Logs errors if file path retrieval fails in getFullPathFromTreeUri().
  • Misc:
    • Minor logging changes in FileUtils.kt to handle exceptions during file path retrieval.

This description was created by Ellipsis for 9be7268. You can customize this summary. It will automatically update as commits are pushed.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Changes requested ❌

Reviewed everything up to 9be7268 in 1 minute and 53 seconds. Click for details.
  • Reviewed 52 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. android/src/main/kotlin/com/mr/flutter/plugin/filepicker/FilePickerDelegate.kt:74
  • Draft comment:
    Improved file saving now uses getFullPathFromTreeUri to return the actual file path. Ensure this handles all content provider cases reliably.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the PR author to ensure that the new method handles all content provider cases reliably. This falls under the rule of not asking the author to ensure behavior is intended or tested. The comment does not provide a specific suggestion or point out a specific issue with the code.

Workflow ID: wflow_4f4xbzjhe7z29dUO

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

val fileName = getFileName(treeUri, con)
if (fileName != null) {
// Try to get the actual path from the URI
val cursor = con.contentResolver.query(treeUri, null, null, null, null)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new block for content URIs queries the '_data' column to determine the file path. Consider specifying a projection (e.g. arrayOf("_data")) to optimize the query. Also note that '_data' may not be available on all content providers and a robust fallback is essential.

Suggested change
val cursor = con.contentResolver.query(treeUri, null, null, null, null)
val cursor = con.contentResolver.query(treeUri, arrayOf("_data"), null, null, null)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant