Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Cannot access file created by takePhoto through FileSystem #1270

Closed
4 tasks done
mortenmo opened this issue Oct 5, 2022 · 4 comments
Closed
4 tasks done

🐛 Cannot access file created by takePhoto through FileSystem #1270

mortenmo opened this issue Oct 5, 2022 · 4 comments
Labels
🐛 bug Something isn't working

Comments

@mortenmo
Copy link

mortenmo commented Oct 5, 2022

What were you trying to do?

Expo 46, iOS,

The picture works fine and can use it, however I cannot access it in any other way.

But doing anything to this file file FileSystem operations (beyond getInfo) fails with a " isn't readable." error.

[Error: File '/private/var/mobile/Containers/Data/Application/D606F8F1-0B4C-41D7-81A8-46AF72BED567/tmp/ReactNative/8CED5BE1-61D5-43B7- ... FF9.jpeg' isn't readable.]

This comment mentions the same issue on an enhancement to be able to select the directory images are stored in.
#893 (comment)

Saving the image to image library does however work using await MediaLibrary.saveToLibraryAsync(path), but permissions there are probably different.

Reproduceable Code

const { path } = await camera.current.takePhoto({
     qualityPrioritization: 'balanced',
});

const file = FileSystem.documentDirectory +
   path.substring(path.lastIndexOf('/') + 1);

await FileSystem.copyAsync({
   from: path,
   to: file,
});

What happened instead?

Besides showing the image in an Image tag, there

Relevant log output

[Error: File '/private/var/mobile/Containers/Data/Application/D606F8F1-0B4C-41D7-81A8-46AF72BED567/tmp/ReactNative/8CED5BE1-61D5-43B7- ... FF9.jpeg' isn't readable.]

Device

iPhone 13

VisionCamera Version

2.14.1

Additional information

@mortenmo mortenmo added the 🐛 bug Something isn't working label Oct 5, 2022
@mortenmo
Copy link
Author

mortenmo commented Oct 5, 2022

MlKit also failed to access the image:

import ImageLabeling from '@react-native-ml-kit/image-labeling';

    ImageLabeling.label(path);   // Fails with image is nil which probably means no access

@mrousavy
Copy link
Owner

Closing as this is a stale issue - this might have been fixed with the full rewrite in VisionCamera V3 (🥳) - if not, please create a new issue.

Try the file:// prefix

@joshua-revolutions
Copy link

joshua-revolutions commented Oct 9, 2023

I got the same issue when sending the photo into Google mlkit. Adding file:// prefix did fix it for me. I'm using v3

@mrousavy
Copy link
Owner

mrousavy commented Oct 9, 2023

Adding file:// prefix did fix it for me

This is not a bug, this is how the filesystem works. It's even in the docs that you need to add this if you want to read the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants