i need to download images from server and display them in the application
Here are my steps:
create directory
download image to this directory
try to display the image file using component
after downloading the image i checked that the file is in the directory using FileSystem.getInfoAsync().
render() {
let groupsDir = FileSystem.documentDirectory + "menuGroups/accounting-alone-application-938965.jpg"
let getInfo = FileSystem.getInfoAsync(groupsDir);
//....some code here
EDIT: The documentation for the return value has been fixed:
Returns
If no item exists at this URI, returns a Promise that resolves to { exists: false, isDirectory: false } . Else returns a Promise that resolves to an object with the following fields:
Original comment below:
I suspect you’re right. FileSystem.getInfoAsync’s API can surely not be as crazy as the documentation describes it:
Returns
If no item exists at this URI, returns a Promise that resolves to { exists: false, isDirectory: false } . Else returns an object with the following fields:
exists ( boolean ) – true .
isDirectory ( boolean ) – true if this is a directory, false if it is a file
modificationTime ( number ) – The last modification time of the file expressed in seconds since epoch.
size ( number ) – The size of the file in bytes. If operating on a source from CameraRoll.getPhotos(), only present if the size option was truthy.
uri ( string ) – A file:// URI pointing to the file. This is the same as the fileUri input parameter.
md5 ( string ) – Present if the md5 option was truthy. Contains the MD5 hash of the file.
i.e. if the file doesn’t exist, return a promise. If it does exist, return an object!?