Ver Fonte

core: Added heic file type, refactor getFileType (#1734)

* add .heic and .heif file types

* refactor getFileType — we don’t need special condition for isRemote anymore
Artur Paikin há 5 anos atrás
pai
commit
4aef626a52

+ 6 - 13
packages/@uppy/utils/src/getFileType.js

@@ -5,21 +5,14 @@ module.exports = function getFileType (file) {
   let fileExtension = file.name ? getFileNameAndExtension(file.name).extension : null
   fileExtension = fileExtension ? fileExtension.toLowerCase() : null
 
-  if (file.isRemote) {
-    // some remote providers do not support file types
-    return file.type ? file.type : mimeTypes[fileExtension]
-  }
-
-  // check if mime type is set in the file object
   if (file.type) {
+    // if mime type is set in the file object already, use that
     return file.type
-  }
-
-  // see if we can map extension to a mime type
-  if (fileExtension && mimeTypes[fileExtension]) {
+  } else if (fileExtension && mimeTypes[fileExtension]) {
+    // else, see if we can map extension to a mime type
     return mimeTypes[fileExtension]
+  } else {
+    // if all fails, fall back to a generic byte stream type
+    return 'application/octet-stream'
   }
-
-  // if all fails, fall back to a generic byte stream type
-  return 'application/octet-stream'
 }

+ 2 - 0
packages/@uppy/utils/src/mimeTypes.js

@@ -12,6 +12,8 @@ module.exports = {
   'jpg': 'image/jpeg',
   'png': 'image/png',
   'gif': 'image/gif',
+  'heic': 'image/heic',
+  'heif': 'image/heif',
   'yaml': 'text/yaml',
   'yml': 'text/yaml',
   'csv': 'text/csv',