Please provide the following:
- SDK Version: 41
- Platforms(Android/iOS/web/all): Android/iOS
- Add the appropriate “Tag” based on what Expo library you have a question on.
Hi,
Please correct me if I have the wrong approach with this, but I figured I could use data already loaded from Firebase, construct it into a string, then use writeAsStringAsync() to write as a .csv file on the device (which I was hoping could be accessed elsewhere for importing into a spreadsheet).
I have the following code which I’ve built using some of the usage example ‘Managing Giphys’ on the documentation. It’s currently producing an error on Expo Go of ‘open failed: EISDIR (Is a directory)’:
import * as FileSystem from 'expo-file-system';
const appDir = FileSystem.documentDirectory + '/BLASiteManager/';
// Checks if directory exists. If not, creates it
const ensureDirExists = async () => {
return new Promise(async (resolve, reject) => {
try {
const dirInfo = await FileSystem.getInfoAsync(appDir);
if (!dirInfo.exists) {
console.log("Directory doesn't exist, creating...");
await FileSystem.makeDirectoryAsync(appDir, { intermediates: true });
}
resolve();
} catch (error) {
reject(error);
}
});
}
export const writeFileToSystem = async (fileString) => {
return new Promise(async (resolve, reject) => {
try {
await ensureDirExists();
console.log("directory check ok, downloading...");
await FileSystem.writeAsStringAsync(appDir, fileString);
resolve("done");
} catch (error) {
reject(error);
}
});
}