diff --git a/src/components/AttachmentPicker/index.native.js b/src/components/AttachmentPicker/index.native.js index f67db30564a4..418be07b819f 100644 --- a/src/components/AttachmentPicker/index.native.js +++ b/src/components/AttachmentPicker/index.native.js @@ -7,6 +7,7 @@ import {Alert, Linking, View} from 'react-native'; import {launchImageLibrary} from 'react-native-image-picker'; import RNDocumentPicker from 'react-native-document-picker'; import RNFetchBlob from 'react-native-blob-util'; +import Str from 'expensify-common/lib/str'; import {propTypes as basePropTypes, defaultProps} from './attachmentPickerPropTypes'; import styles from '../../styles/styles'; import Popover from '../Popover'; @@ -65,8 +66,13 @@ const documentPickerOptions = { * @return {Promise} */ function getDataForUpload(fileData) { + let fileName = fileData.fileName || fileData.name || 'chat_attachment'; + const fileExtension = `.${_.last(fileData.type.split('/'))}`; + if (!Str.endsWith(fileName, fileExtension)) { + fileName = `${fileName}${fileExtension}`; + } const fileResult = { - name: fileData.fileName || fileData.name || 'chat_attachment', + name: fileName, type: fileData.type, uri: fileData.fileCopyUri || fileData.uri, size: fileData.fileSize || fileData.size,