I’m looking into ways to preserve an avatar picture taken with ImagePicker.
using AsyncStorage seems to be a no go since there’s size limitation.
So I’m trying to figure out how to use FileSystem.
What I understand is that:
- After I get the base64 encoded image from ImagePicker, I need to make a directory to store it by using
- Then I have to save the image using
- Retrieve it by using
My question is:
- The doc said that
cacheDirectoryis for one use only since it may be deleted any time on system’s discretion, does that mean in my case if I want to save this avatar permanently I have to use
fileDirectoryinstead in the above scenario?
- When the app is deleted, will the saved file deleted with the app or is that something I have to explicitly handle? (in cases of cacheDirectory and fileDirectory)
- When user renews the avatar by taking new picture and
makeDirectoryAsyncis called again with the same exact command as written above for the second time and on, would it give me error saying the directory already exist or something like that?
- When user take new picture and save in the
/avatardirectory, would it be saved as
/avatar/image2or will it overwrite
Sorry for the basic questions, I just can’t seem to find any clue as to what happens in the background just based on the documentations…
And I know it’s weird, saving avatar to phone instead of to server then retrieving it from there but it’s just a hack-style decision by my project manager so yeah I have to find out how to do this properly. lol
Thanks in advance!
based on #1245,
readAsStringAsync() could not be used for jpeg, is this still the case now? and if it is, is there any way I can make my use case work?