Skip to content

Commit

Permalink
Merge pull request #51290 from Expensify/rodrigo-fix-csv-download-hybrid
Browse files Browse the repository at this point in the history
Adds folder picker when downloading CSV on iOS
  • Loading branch information
iwiznia authored Oct 28, 2024
2 parents 4aa19bf + 4a1f24d commit 1151eca
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/libs/fileDownload/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {CameraRoll} from '@react-native-camera-roll/camera-roll';
import type {PhotoIdentifier} from '@react-native-camera-roll/camera-roll';
import RNFetchBlob from 'react-native-blob-util';
import RNFS from 'react-native-fs';
import Share from 'react-native-share';
import CONST from '@src/CONST';
import * as FileUtils from './FileUtils';
import type {FileDownload} from './types';
Expand Down Expand Up @@ -47,15 +48,13 @@ const postDownloadFile = (url: string, fileName?: string, formData?: FormData, o
.then((fileData) => {
const finalFileName = FileUtils.appendTimeToFileName(fileName ?? 'Expensify');
const expensifyDir = `${RNFS.DocumentDirectoryPath}/Expensify`;

const localPath = `${expensifyDir}/${finalFileName}`;
return RNFS.mkdir(expensifyDir).then(() => {
const localPath = `${expensifyDir}/${finalFileName}`;
return RNFS.writeFile(localPath, fileData, 'utf8').then(() => localPath);
return RNFS.writeFile(localPath, fileData, 'utf8')
.then(() => Share.open({url: localPath, failOnCancel: false, saveToFiles: true}))
.then(() => RNFS.unlink(localPath));
});
})
.then(() => {
FileUtils.showSuccessAlert();
})
.catch(() => {
if (!onDownloadFailed) {
FileUtils.showGeneralErrorAlert();
Expand Down

0 comments on commit 1151eca

Please sign in to comment.