Skip to content

Commit

Permalink
Merge pull request #7277 from kidroca/kidroca/android-document-picker…
Browse files Browse the repository at this point in the history
…-fix

[CP Staging] Fix document upload on Android
  • Loading branch information
mountiny authored Jan 17, 2022
2 parents 2b7f6a7 + d035647 commit e63788d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/AttachmentPicker/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ function getDataForUpload(fileData) {
size: fileData.fileSize || fileData.size,
};

// When the URI is lacking uri scheme - file upload would fail
// Prefixing the uri with `file://` fixes attachment upload on Android
const hasScheme = /^.+:\/\//.test(fileResult.uri);
if (!hasScheme) {
fileResult.uri = `file://${fileResult.uri}`;
}

if (fileResult.size) {
return Promise.resolve(fileResult);
}
Expand Down Expand Up @@ -198,7 +205,6 @@ class AttachmentPicker extends Component {
return reject(new Error(`Error during attachment selection: ${response.errorMessage}`));
}

// Resolve with the first (and only) selected file
return resolve(response.assets);
});
});
Expand Down

0 comments on commit e63788d

Please sign in to comment.