Interview frequency: …
Short answer
Use expo-file-system to download files to DocumentDirectory or CacheDirectory, then use expo-sharing to share them with other apps.
Explanation
DocumentDirectory is for permanent user-owned files that remain available in backups, while CacheDirectory is for temporary files that the system may delete when storage is low. Sharing.shareAsync opens the native system share sheet to send reports and PDFs through email or WhatsApp.
Code example
import * as FileSystem from 'expo-file-system';
import * as Sharing from 'expo-sharing';
async function downloadAndSharePDF(url: string) {
const fileUri = FileSystem.documentDirectory + 'invoice.pdf';
const downloadResult = await FileSystem.downloadAsync(url, fileUri);
if (await Sharing.isAvailableAsync()) {
await Sharing.shareAsync(downloadResult.uri);
}
}Common mistakes
- Saving large temporary cache files in DocumentDirectory, increasing the app's iCloud and Google Drive backup size.