What I want to achieve with the below code is get info for individual files so that I can sort the files according to the modified time.
const permissions =
await StorageAccessFramework.requestDirectoryPermissionsAsync();
if (permissions.granted) {
try {
let uri = permissions.directoryUri;
let files = await StorageAccessFramework.readDirectoryAsync(
uri
);
const fileObjects = [];
for (const file of files) {
const fileStat = await getInfoAsync(
file
);
fileObjects.push({
uri: fileStat.uri,
time: fileStat.modificationTime,
});
}
fileObjects.sort((a, b) => b.time - a.time);
setStatusFiles(fileObjects);
} catch (error) {
console.log(error);
}
}
I tried logging the results of the function within the loop but I only get the following info.
{“exists”: true, “isDirectory”: false, “size”: 109448, “uri”: “content://com…”}