Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CP Staging] fix: create object uri for import spreadsheets #48574

Merged
merged 4 commits into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -98,6 +98,9 @@ function ImportSpreedsheet({backTo, goTo}: ImportSpreedsheetProps) {
})
.finally(() => {
setIsReadingFIle(false);
if (fileURI && !file.uri) {
URL.revokeObjectURL(fileURI);
}
});
};

Expand Down Expand Up @@ -185,7 +188,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
Loading