How can we save an image in my react native app, clicked by accessing the camera from my react native app.
I intend to use and upload the image in later steps to the server till then I only have to save the clicked image in my react native app.
How can I possibly do this?
Currently I am using this library for accessing the image from my gallery as well as device camera. https://github.com/expo/image-upload-example/
I tried that, here is my code:
FileSystem.moveAsync({
from: pickerResult.uri,
to: FileSystem.documentDirectory + ‘images/imagename.png’
})
I get the following error:
[Unhandled promise rejection: Error: File ‘file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540singhalok641%252Fmod/ImagePicker/453428b3-ab61-42bd-bb57-f7d4e9fb442d.jpg’ could not be moved to ‘file:///data/user/0/host.exp.exponent/files/ExperienceData/%2540singhalok641%252Fmod/images/imagename.png’]
Thanks @tsapeta
I tried creating the directory and I get this new error:
Unhandled promise rejection: Error: Directory ‘file:///data/data/host.exp.exponent/cache/ExperienceData/%2540singhalok641%252Fmod/ImagePicker/33af79d3-eeaf-4d42-9139-af272ce4af0a.jpg’ could not be created.
@singhalok641
That error is fine since you’re trying to create a directory at path that already exists (there is a jpg file at this path, the uri is what you received from ImagePicker). Try something like this:
Thanks @tsapeta
I tried the above same code and I get the same error:
Unhandled promise rejection: Error: Directory ‘file:///data/data/host.exp.exponent/files/ExperienceData/%2540singhalok641%252Fmod/images/’ could not be created.