Pārlūkot izejas kodu

xhrupload,tus,transloadit: Ignore errored files.

Renée Kooi 7 gadi atpakaļ
vecāks
revīzija
4682f59fc6
3 mainītis faili ar 12 papildinājumiem un 2 dzēšanām
  1. 6 0
      src/plugins/Transloadit/index.js
  2. 3 1
      src/plugins/Tus.js
  3. 3 1
      src/plugins/XHRUpload.js

+ 6 - 0
src/plugins/Transloadit/index.js

@@ -317,6 +317,9 @@ module.exports = class Transloadit extends Plugin {
   }
   }
 
 
   prepareUpload (fileIDs, uploadID) {
   prepareUpload (fileIDs, uploadID) {
+    // Only use files without errors
+    fileIDs = fileIDs.filter((file) => !file.error)
+
     fileIDs.forEach((fileID) => {
     fileIDs.forEach((fileID) => {
       this.core.emit('core:preprocess-progress', fileID, {
       this.core.emit('core:preprocess-progress', fileID, {
         mode: 'indeterminate',
         mode: 'indeterminate',
@@ -367,6 +370,9 @@ module.exports = class Transloadit extends Plugin {
   }
   }
 
 
   afterUpload (fileIDs, uploadID) {
   afterUpload (fileIDs, uploadID) {
+    // Only use files without errors
+    fileIDs = fileIDs.filter((file) => !file.error)
+
     const state = this.getPluginState()
     const state = this.getPluginState()
     const assemblyIDs = state.uploadsAssemblies[uploadID]
     const assemblyIDs = state.uploadsAssemblies[uploadID]
 
 

+ 3 - 1
src/plugins/Tus.js

@@ -364,7 +364,9 @@ module.exports = class Tus extends Plugin {
       const current = parseInt(index, 10) + 1
       const current = parseInt(index, 10) + 1
       const total = files.length
       const total = files.length
 
 
-      if (!file.isRemote) {
+      if (file.error) {
+        return Promise.reject(new Error(file.error))
+      } else if (!file.isRemote) {
         return this.upload(file, current, total)
         return this.upload(file, current, total)
       } else {
       } else {
         return this.uploadRemote(file, current, total)
         return this.uploadRemote(file, current, total)

+ 3 - 1
src/plugins/XHRUpload.js

@@ -252,7 +252,9 @@ module.exports = class XHRUpload extends Plugin {
       const current = parseInt(i, 10) + 1
       const current = parseInt(i, 10) + 1
       const total = files.length
       const total = files.length
 
 
-      if (file.isRemote) {
+      if (file.error) {
+        return Promise.reject(new Error(file.error))
+      } else if (file.isRemote) {
         return this.uploadRemote(file, current, total)
         return this.uploadRemote(file, current, total)
       } else {
       } else {
         return this.upload(file, current, total)
         return this.upload(file, current, total)