#how can be use camera If we are using react and call to this camera apiHow can we use camera

1 messages · Page 1 of 1 (latest)

wintry notch
#

`Route::get('/camera', [CameraController::class, 'camera']);

public function camera(Request $request)
{
try {
$photo = Camera::pickImages('all', true);
return response()->json([
'success' => true,
'photo' => $photo,
]);

    } catch (\Exception $e) {
        // Handle errors (like permission denied)
        return response()->json([
            'success' => false,
            'message' => 'Failed to capture photo: ' . $e->getMessage(),
        ], 500);
    }
}`

What technology used for this ?

use Native\Mobile\Facades\Camera; Route::get('/open-external', function () { Camera::pickImages('all', true); })->name('open-external');

its working if i call like this

versed trout
#

Haven't tried working with camera myself, but I can try to help.

Based on the documentation I think you can do this.

You call the Camera::pickImages('all', true); to open users gallery.

Users selects their images.

As you are not using livewire you could try to listen for this in the react side.

 window.addEventListener("native:Native\\Mobile\\Events\\Gallery\\MediaSelected", myFunctionToWorkWithTheMedia);

or perhaps it just works like this:

 window.addEventListener("native:MediaSelected", myFunctionToWorkWithTheMedia);

Then ->

myFunctionToWorkWithTheMedia(event) { console.log(event); }

Figure out the rest.

#

Don't take my word for granted, it's just an guess based on the limited documentation we have.