gre / react-native-view-shot

Snapshot a React Native view and save it to an image
https://github.com/gre/react-native-view-shot-example
MIT License
2.66k stars 345 forks source link

Android returns relative path instead of absolute path #383

Open EsraaMahmoudMohamed opened 2 years ago

EsraaMahmoudMohamed commented 2 years ago

bug report

when using simulator we get the absolute path for image uri

/Users/<user-name>/Library/Developer/CoreSimulator/Devices/1A59B43E-F0E3-4C58-9D4C-C37E784D9FE0/data/Containers/Data/Application/76F43B2B-FCE7-4D6B-AAD8-D3332AB8A0BF/tmp/ReactNative/B9DEF3D7-D357-4224-B32A-A185C23A0C04.png 

but when we use the emulator we get relative path

file:///data/user/0/<app-package-name>/cache/ReactNative-snapshot-image8476334127067790968.png

when we try to use open command to open the image it always fail with error

The file /Users/<user-name>/file:/data/user/0/<app-package-name>/cache/ReactNative-snapshot-image8476334127067790968.png does not exist.

Version & Platform

react-native-view-shot Version 3.1.2 react-native Version 0.64.1

Platform: Android

Expected behavior

view-shot returns an absolute path in Android like IOS

Actual behavior

view-shot returns a relative path in Android

aeroplaniko commented 2 years ago

you can check https://stackoverflow.com/a/44089388

Seanmclem commented 2 years ago

Expected behavior

view-shot returns an absolute path in Android like IOS

Actual behavior

view-shot returns a relative path in Android

That's one way to confirm if the image is there. What about -

Expected behavior

view-shot returns an absolute path in Android like IOS

Actual behavior

view-shot returns a relative path in Android

gre commented 2 years ago

AFAIK file:/// format is the standard way that get accepted by other libraries too like react-native-fs or Image Editor, so we need more detail why this is a problem.