Kex Kex - 2 months ago 236
iOS Question

Alamofire 4.0 ambiguous reference on upload

I am trying to upload using alamofire, I am using the following code:

Alamofire.upload(urlRequest.0, to: urlRequest.1, method: .put)
.uploadProgress(queue: DispatchQueue.utility) { progress in
print("Upload Progress: \(progress.fractionCompleted)")
}

.responseJSON { response in
//Some code here

}


Where
urlRequest
is a tuple:
(URLConvertible, Data)
. I am getting the compiler error :
"Ambiguous reference to member 'upload(_:to:method:headers:)'"
. Any ideas what I am doing wrong here? Any pointers would be really appreciated! Thanks!

Answer

You may need to add the headers parameter:

Alamofire.upload(urlRequest.0, to: urlRequest.1, method: .put, headers: nil) { ...

while a tuple's types should stand in this order: (Data, URLConvertible)