         let pendingUploads = TUSClient.shared.pendingUploads()
         return pendingUploads.count > 0 && (uploadWholeQueueInBackground || !isAppBackground)
     }
+
+    // TODO: Retry-Mechanism: The places where we called `markAsFailed` are the places where we could retry uploading the failed chunk.
+    internal func markAsFailed(upload: TUSUpload, completion: @escaping (Bool) -> Void, error: Error?) {
+        cancel(forUpload: upload, error: error, failed: true)
+
+        if continueUploading() {
+            let pendingUploads = TUSClient.shared.pendingUploads()
+            TUSClient.shared.createOrResume(forUpload: pendingUploads[0])
+        } else {
+            completion(false)
+        }
+    }
 }

    ///
    private func prepareUpload(
        forUpload upload: TUSUpload,
        callback: @escaping ([Data], Bool) -> Void
    ) {
        /*

            }
            
            // Do the work:
            do {
                let data = try upload.getData()
                if (skipResumeCheck) {
                    let chunks = self.dataIntoChunks(data: data, chunkSize: TUSClient.shared.chunkSize)
                    startUpload(chunks: chunks)
                } else {
                    self.prepareUpload(forUpload: upload, uploadData: data) { (chunks, skipUploadMarkSuccess) in
                        if (skipUploadMarkSuccess) {
                            self.handleUploadSuccess(upload: upload, completion: uploadFinishedCallback)
                        } else {
                            startUpload(chunks: chunks)
                        }
                    }
                }
            } catch {
                self.markAsFailed(upload: upload, completion: uploadFinishedCallback, error: error)
            }
        }
    }
