我们如何在 Alamofire 4.0 的上传功能中添加认证头?
下面是示例代码,但是我看不到向函数添加标头的方法。
Alamofire.upload(
multipartFormData: { multipartFormData in
multipartFormData.append(unicornImageURL, withName: "unicorn")
multipartFormData.append(rainbowImageURL, withName: "rainbow")
},
to: "https://httpbin.org/post",
encodingCompletion: { encodingResult in
switch encodingResult {
case .success(let upload, _, _):
upload.responseJSON { response in
debugPrint(response)
}
case .failure(let encodingError):
print(encodingError)
}
}
)
之前版本的alamofire支持直接添加header,新版本不支持。有任何想法吗?