Skip to content

Commit

Permalink
Merge pull request #48574 from mkzie2/mkzie2-issue-48533
Browse files Browse the repository at this point in the history
[CP Staging] fix: create object uri for import spreadsheets
  • Loading branch information
MariaHCD authored Sep 5, 2024
2 parents 35d31f3 + 37694a3 commit fdc0585
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/components/ImportSpreadsheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ function ImportSpreedsheet({backTo, goTo}: ImportSpreedsheetProps) {
if (!validateFile(file)) {
return;
}
if (!file.uri) {
let fileURI = file.uri ?? URL.createObjectURL(file);
if (!fileURI) {
return;
}
let filePath = file.uri;
if (Platform.OS === 'ios') {
filePath = filePath.replace(/^.*\/Documents\//, `${RNFetchBlob.fs.dirs.DocumentDir}/`);
fileURI = fileURI.replace(/^.*\/Documents\//, `${RNFetchBlob.fs.dirs.DocumentDir}/`);
}

fetch(filePath)
fetch(fileURI)
.then((data) => {
setIsReadingFIle(true);
return data.arrayBuffer();
Expand All @@ -102,6 +102,9 @@ function ImportSpreedsheet({backTo, goTo}: ImportSpreedsheetProps) {
})
.finally(() => {
setIsReadingFIle(false);
if (fileURI && !file.uri) {
URL.revokeObjectURL(fileURI);
}
});
};

Expand Down Expand Up @@ -189,7 +192,7 @@ function ImportSpreedsheet({backTo, goTo}: ImportSpreedsheetProps) {
height={CONST.IMPORT_SPREADSHEET.ICON_HEIGHT}
/>
<Text style={[styles.textFileUpload]}>{translate('common.dropTitle')}</Text>
<Text style={[styles.subTextFileUpload, styles.textSupporting]}>{translate('common.dropMessage')}</Text>
<Text style={[styles.subTextFileUpload, styles.themeTextColor]}>{translate('common.dropMessage')}</Text>
</View>
</View>
</DragAndDropConsumer>
Expand Down

0 comments on commit fdc0585

Please sign in to comment.