Selaa lähdekoodia

[FIX] - improve MIME type detection to solve issue in iOS Safari where the first Blob in the Array might not have a MIME type specified and so would crash the Webcam component. (#2851)

Dominic Eden 4 vuotta sitten
vanhempi
commit
b2e04962df
1 muutettua tiedostoa jossa 5 lisäystä ja 1 poistoa
  1. 5 1
      packages/@uppy/webcam/src/index.js

+ 5 - 1
packages/@uppy/webcam/src/index.js

@@ -518,7 +518,11 @@ module.exports = class Webcam extends Plugin {
   }
 
   getVideo () {
-    const mimeType = this.recordingChunks[0].type
+    // Sometimes in iOS Safari, Blobs (especially the first Blob in the recordingChunks Array)
+    // have empty 'type' attributes (e.g. '') so we need to find a Blob that has a defined 'type'
+    // attribute in order to determine the correct MIME type.
+    const mimeType = this.recordingChunks.find(blob => blob.type?.length > 0).type
+
     const fileExtension = getFileTypeExtension(mimeType)
 
     if (!fileExtension) {