How to save Images using Expo Filesystem?

#1

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.

0 Likes

FileSystem makeDirectory and downloadAsync not cooperating
#2

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.

0 Likes

#3

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.]

https://snack.expo.io/Skdxa-5cf

0 Likes

#4

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.]

https://snack.expo.io/Skdxa-5cf
[/quote]

0 Likes

#5

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 https://snack.expo.io/rJBtdY-sz but I’m not sure how to trigger the issue.

1 Like

closed #6

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

0 Likes