Skip to content

Commit de10343

Browse files
fix(iOS): Ensure MultiUploadTask filename is always a list
The `Uploader.swift` was incorrectly modifying the `filename` property of a `MultiUploadTask` to a single string when only one file was present. This caused a JSON deserialization error on the Dart side, as `MultiUploadTask.fromJson` expects a list of strings. This commit adds a check to ensure that the `filename` property is only modified for regular `UploadTask`s, preserving the list format for `MultiUploadTask`s regardless of the number of files. Fixes #510
1 parent dad28cc commit de10343

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

ios/background_downloader/Sources/background_downloader/Uploader.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ public class Uploader : NSObject, URLSessionTaskDelegate, StreamDelegate {
9292
return false
9393
}
9494
let derivedFilename = path.components(separatedBy: "/").last!
95-
if filesData.count == 1 {
95+
if filesData.count == 1 && task.taskType != "MultiUploadTask" {
9696
// only for single file uploads do we set the task's filename property
97-
9897
let newTask = task.copyWith(filename: maybeFileUri != nil
9998
? pack(filename: derivedFilename, uri: maybeFileUri!)
10099
: derivedFilename)

0 commit comments

Comments
 (0)