While trying to use the AWSTransferutility to upload photos with Swift, I get this error. Ambiguous reference to member async(execute:) I searched similar questions but didn't find solution.
func uploadS3Background (dict: NSMutableDictionary) {
let transferUtility = AWSS3TransferUtility.default()
let expression = AWSS3TransferUtilityUploadExpression()
let completionHandler = { (task, error) -> Void in
DispatchQueue.main.async(execute: {
})
}
transferUtility.uploadFile(URL(fileURLWithPath: dict.object(forKey: "url") as! String),
bucket: "bucketname/images",
key: (dict.object(forKey: "filename") as! String),
contentType: "image/png",
expression: expression,
completionHandler).continueWith { (task) -> AnyObject! in
if let error = task.error
{
print("Error: \(error.localizedDescription)")
}
if let _ = task.result
{
// Do something with uploadTask.
}
return nil;
}
}
Outside of a completion block I don't get the error for dispatching on the main queue.
Declare this in your view controller -
var completionHandler: AWSS3TransferUtilityUploadCompletionHandlerBlock?
and then use
self.completionHandler = { (task, error) -> Void in
DispatchQueue.main.async(execute: {
})
}