简体   繁体   English

在 Alamofire 中上传图像时是否可以有更小的数据包?

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

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问题是与 downloadProgress 相比,uploadProgress 刷新时间太长

is there any way to make uploadProgress update more frequently?有什么方法可以让uploadProgress 更新更频繁?

btw: im using alamofire 5顺便说一句:我正在使用 alamofire 5

No. Alamofire is at the mercy of the progress callbacks from URLSession .不,Alamofire 受来自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 now 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.因此,您会看到一段时间的 now 进度,然后是真正的上传进度,然后是快速下载进度,因为下载部分通常只是服务器确认上传,而且要小得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM