Is it possible to have smaller packets when uploading images in Alamofire?

21 Views Asked by At

my code is something like this:

Alamofire.upload(multipartFormData: { (data) in 
  // add bunch of large size images 
}
.uploadProgress { progress in
  // print progress
}
.downloadProgress { progress in
  // print progress
}

the problem is that uploadProgress takes too long to refresh compared to downloadProgress

is there any way to make uploadProgress update more frequently?

btw: im using alamofire 5

1

There are 1 best solutions below

1
Jon Shier On BEST ANSWER

No. Alamofire is at the mercy of the progress callbacks from URLSession. You should also know that if your upload is over the threshold, it's first written to disk, which is not reflected in the progress. So you'll see a period of no progress, then the real upload progress, then quick download progress, as the download part is usually just the server acknowledging the upload and is much smaller.