Skip to content

Android: Receiving inaccessible /storage/... path instead of content:// URI when sharing files #132

@sanjay-wolet

Description

@sanjay-wolet

Problem: When sharing files (e.g., PDFs) to the app from certain sources (like the native File Manager or Telegram) on Android, the package provides a direct file system path (e.g., /storage/emulated/0/Android/data/.../file.pdf) instead of a content:// URI.

This direct path is often inaccessible to the app due to Android's scoped storage restrictions, leading to PathNotFoundException or permission errors when trying to read the file using either dart:io.File or content_resolver.

Steps to Reproduce:

Install the app on an Android device (e.g., I2208, Android [Android Version]).

Go to the device's File Manager or Telegram.

Select a PDF file.

Tap the "Share" button.

Choose the app from the share sheet.

Observe the path received by the receive_sharing_intent (or share_handler) stream listener in the app's logs.

Expected Behavior: The app should receive a standard content:// URI for the shared file, which can then be reliably processed using the content_resolver package to get the file's bytes.

Actual Behavior: The app receives a direct file path starting with /storage/emulated/0/.... Attempts to access this path using dart:io.File(path).exists() or dart:io.File(path).readAsBytes() fail with PathNotFoundException (OS Error: No such file or directory, errno = 2) or permission errors. Attempts to use content_resolver on this path also fail because it's not a valid content URI.

Device Details:

Device: I2208

Android Version: [Your Android Version] (e.g., Android 13, Android 14)

receive_sharing_intent (or share_handler) Version: [Package Version from pubspec.lock]

Relevant Logs:

I/flutter (...): === SHARE STREAM EVENT ===
I/flutter (...): Received shared media: ...
I/flutter (...): Attachments: [SharedAttachment(path: /storage/emulated/0/Android/data/rs.kinta.app/files/Download/Telegram/Kinta-All-Receipts-2025-10-29T16-38-30.pdf, type: SharedAttachmentType.file)]
...
I/flutter (...): Path looks like direct path. Trying dart:io.File...
I/flutter (...): ❌ Direct path file does not exist or is not accessible.
I/flutter (...): ❌ Failed to get file bytes using any method.
Additional Context: This issue prevents the app from reliably handling files shared from common sources on Android due to inaccessible paths being provided by the package. The expected behavior is to always receive a content:// URI that respects scoped storage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions