Skip to content

Bug: PhotoTaken returns inaccessible Android path #8

Description

@ngomory

Hello

Environment

  • NativePHP Mobile Camera: 1.0.3
  • Laravel: 12
  • Android APK build

Problem

After taking a photo, the PhotoTaken event returns an Android private cache path:

/data/user/0/com.domain.app/cache/captured_1783458827316.jpg

But this path is not accessible from PHP:

file_exists($path); // false
is_dir(dirname($path)); // false

The PHP runtime cannot read the file because this path belongs to the Android native layer.

Expected behavior

The plugin should provide a way to access the captured image from PHP.

Possible solutions:

Send the image content (Base64/blob) with the PhotoTaken event.
or
Copy the file to a location accessible by the PHP runtime before dispatching the event.

Example:

#[OnNative(PhotoTaken::class)]
public function photoTaken(string $path)
{
    Storage::put(
        'photos/photo.jpg',
        file_get_contents($path) // or base64_decode($path)
    );
}

should work after the fix.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions