How to save Images using Expo Filesystem?

How to save the images into a folder in the app from image url in an Api. and save that path in sqlite.

I tried Expo.FileSystem.makeDirectoryAsync(fileUri, options) for creating a directory then i download the images with Expo.FileSystem.downloadAsync(uri, fileUri, options) and then i move this to the folder when i created Expo.FileSystem.moveAsync(options) . But only thing working will be i can only download the images from the api but the image is download to the Expo.FileSystem.documentDirectory and getting the uri as

file:///data/user/0/host.exp.exponent/files/ExperienceData/%2540tester%252Ftestv1/5ab1ed5805030.jpg

and in console i got
[Unhandled promise rejection: Error: Directory ‘file:///data/user/0/host.exp.exponent/files/ExperienceData/%2540tester%252Ftestv1//testfolder/’ could not be created.

How to process the images and create directory and move the file to the created directory.

Hi @shibi! Can you create a Snack with the code that’s failing? It’s easier for us to debug if we can just open up the code and try it.

Thanks for your response. I create a snack with code failing please help.
the error now geting is
[Unhandled promise rejection: Error: FileSystem.moveAsync needs a from path.]

Thanks for your response. I create a snack with code failing please help.

the error now geting is

[Unhandled promise rejection: Error: FileSystem.moveAsync needs a from path.]

[/quote]

Hey @shibi! That snack had some syntax errors, and it’s kind of hard to tell what’s going on. Would be really useful if just the issue with FileSystem was isolated. I cleaned up the snack to work here Image save in expo - Snack but I’m not sure how to trigger the issue.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.