Skip to content

Commit fdc0585

Browse files
authored
Merge pull request #48574 from mkzie2/mkzie2-issue-48533
[CP Staging] fix: create object uri for import spreadsheets
2 parents 35d31f3 + 37694a3 commit fdc0585

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/components/ImportSpreadsheet.tsx

+8-5
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ function ImportSpreedsheet({backTo, goTo}: ImportSpreedsheetProps) {
7575
if (!validateFile(file)) {
7676
return;
7777
}
78-
if (!file.uri) {
78+
let fileURI = file.uri ?? URL.createObjectURL(file);
79+
if (!fileURI) {
7980
return;
8081
}
81-
let filePath = file.uri;
8282
if (Platform.OS === 'ios') {
83-
filePath = filePath.replace(/^.*\/Documents\//, `${RNFetchBlob.fs.dirs.DocumentDir}/`);
83+
fileURI = fileURI.replace(/^.*\/Documents\//, `${RNFetchBlob.fs.dirs.DocumentDir}/`);
8484
}
8585

86-
fetch(filePath)
86+
fetch(fileURI)
8787
.then((data) => {
8888
setIsReadingFIle(true);
8989
return data.arrayBuffer();
@@ -102,6 +102,9 @@ function ImportSpreedsheet({backTo, goTo}: ImportSpreedsheetProps) {
102102
})
103103
.finally(() => {
104104
setIsReadingFIle(false);
105+
if (fileURI && !file.uri) {
106+
URL.revokeObjectURL(fileURI);
107+
}
105108
});
106109
};
107110

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

0 commit comments

Comments
 (0)