diff options
author | Chris <ccbrown112@gmail.com> | 2017-09-05 12:13:03 -0500 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-09-05 13:13:03 -0400 |
commit | c4e32060bef6ad2c6a2c8dfb8cdb8ad34d0f302e (patch) | |
tree | 7d47e35f483ea476f71371e08fb92f325c43750d /webapp/components/file_upload.jsx | |
parent | 575864c917dbbe6b58d3e4534c3015327f2cb088 (diff) | |
download | chat-c4e32060bef6ad2c6a2c8dfb8cdb8ad34d0f302e.tar.gz chat-c4e32060bef6ad2c6a2c8dfb8cdb8ad34d0f302e.tar.bz2 chat-c4e32060bef6ad2c6a2c8dfb8cdb8ad34d0f302e.zip |
fix svg thumbnails and non-png copy/pastes (#7348)
Diffstat (limited to 'webapp/components/file_upload.jsx')
-rw-r--r-- | webapp/components/file_upload.jsx | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/webapp/components/file_upload.jsx b/webapp/components/file_upload.jsx index 9ec4aaf2f..eb966aeed 100644 --- a/webapp/components/file_upload.jsx +++ b/webapp/components/file_upload.jsx @@ -250,11 +250,7 @@ class FileUpload extends React.Component { for (let i = 0; i < e.clipboardData.items.length; i++) { const item = e.clipboardData.items[i]; - if (item.type.indexOf('image') === -1) { - continue; - } - - if (Constants.IMAGE_TYPES.indexOf(item.type.split('/')[1].toLowerCase()) === -1) { + if (item.kind !== 'file') { continue; } @@ -279,8 +275,9 @@ class FileUpload extends React.Component { for (var i = 0; i < items.length && i < numToUpload; i++) { var file = items[i].getAsFile(); - - var ext = items[i].type.split('/')[1].toLowerCase(); + if (!file) { + continue; + } // generate a unique id that can be used by other components to refer back to this file upload var clientId = Utils.generateId(); @@ -299,7 +296,8 @@ class FileUpload extends React.Component { min = String(d.getMinutes()); } - const name = formatMessage(holders.pasted) + d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + hour + '-' + min + '.' + ext; + const ext = file.name.lastIndexOf('.'); + const name = formatMessage(holders.pasted) + d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + hour + '-' + min + (ext >= 0 ? file.name.substr(ext) : ''); const request = uploadFile( file, |