Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 12 additions & 3 deletions src/components/AttachmentModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,20 @@ function AttachmentModal(props) {
}

if (_file instanceof File) {
const inputSource = URL.createObjectURL(_file);
const inputModalType = getModalType(inputSource, _file);
/**
* Cleaning file name, done here so that it covers all cases:
* upload, drag and drop, copy-paste
*/
let updatedFile = _file;
const cleanName = FileUtils.cleanFileName(updatedFile.name);
if (updatedFile.name !== cleanName) {
updatedFile = new File([updatedFile], cleanName, {type: updatedFile.type});
}
const inputSource = URL.createObjectURL(updatedFile);
const inputModalType = getModalType(inputSource, updatedFile);
setIsModalOpen(true);
setSource(inputSource);
setFile(_file);
setFile(updatedFile);
setModalType(inputModalType);
} else {
const inputModalType = getModalType(_file.uri, _file);
Expand Down
8 changes: 1 addition & 7 deletions src/components/AttachmentPicker/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {useRef} from 'react';
import CONST from '../../CONST';
import {propTypes, defaultProps} from './attachmentPickerPropTypes';
import * as FileUtils from '../../libs/fileDownload/FileUtils';

/**
* Returns acceptable FileTypes based on ATTACHMENT_PICKER_TYPE
Expand Down Expand Up @@ -35,14 +34,9 @@ function AttachmentPicker(props) {
type="file"
ref={fileInput}
onChange={(e) => {
let file = e.target.files[0];
const file = e.target.files[0];

if (file) {
const cleanName = FileUtils.cleanFileName(file.name);
if (file.name !== cleanName) {
file = new File([file], cleanName);
Comment thread
alitoshmatov marked this conversation as resolved.
}
file.uri = URL.createObjectURL(file);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We forgot to attach the .uri property back above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Li357 You are right it has caused regression, and we fixed it in another PR - #22903

onPicked.current(file);
}

Expand Down