ios - 跟踪 Alamofire 请求中的进度
问题描述
我想知道是否可以显示请求的进度。我将图像转换为 base64 字符串并使用参数将其发送到我的服务器。有没有办法跟踪它的进度?我想尝试类似的东西。但我无法在我的 Alamofire.request 中添加进度部分。有什么我想念的吗?
Alamofire.request(.POST, URL, parameters: parameter, encoding: .JSON)
.progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
// track progress here
}
.responseJSON { response in
// Do your stuff
}
解决方案
不确定,但我认为当前版本的 Alamofire 使用downloadProgress
而不是progress
:
Alamofire.request(/* ... */).downloadProgress { progress in
progress.fractionCompleted // value between 0 and 1
}
.responseJSON { /* ... */ }
推荐阅读
- c++ - use QModelIndex to set background of a QTreeWidgetItem
- c++ - 使用 QMap 并获取编译错误消息
- upgrade - MarkLogic 升级和步骤
- android - 如何以编程方式检查 VoLTE 启用
- javascript - 如何从第三方 REST API 获取数据并显示在页面上
- java - 如何在java中将`List`更改为`List of tuple`
- javascript - uuid - 默认导出 (ReactJS - JavaScript)
- c - 如何使大容量存储设备从固件只读到 Windows
- c# - 从基类实例化特定类型的派生类属性
- php - Laravel Blade 变量范围