Aws-sdk-ios: Problem with transferUtility?.getUploadTasks()

Created on 4 Dec 2015  路  3Comments  路  Source: aws-amplify/aws-sdk-ios

I am trying to get the list of current upload tasks. For some reason when I call getUploadTasks on my AWSS3TransferUtility object I am being returned an AWSTask rather than an array of AWSS3TransferUtilityUploadTask objects as the documentation suggests here http://docs.aws.amazon.com/AWSiOSSDK/latest/Classes/AWSS3TransferUtility.html#//api/name/getAllTasks

Here is my code:

let transferUtility = AWSS3TransferUtility.defaultS3TransferUtility()
if let uploadTasks = transferUtility?.getUploadTasks() { 
//uploadTasks is an AWSTask object rather than an array of AWSS3TransferUtilityUploadTask objects
     for uploadTask in uploadTasks {
          print("uploadTask")
     }
}
question

Most helpful comment

Got this working! For anyone trying to do something similar this is what it looks like:

let transferUtility = AWSS3TransferUtility.defaultS3TransferUtility()
        transferUtility?.getUploadTasks().continueWithBlock({
            (task) in
            print("getUploadTasks ContinueBlock")
            if let uploadTasks = task.result as? [AWSS3TransferUtilityUploadTask] {

            }
            return nil
        })

All 3 comments

You need to use - continueWithBlock: and retrieve the list of tasks from task.result. See Working with AWSTask for more details.

Not sure what is in task.result because it is an any object... can't seem to find class reference for awstask either.
Edit: Essentially I just need to retrieve a list of the keys synchronously that are currently uploading.

Got this working! For anyone trying to do something similar this is what it looks like:

let transferUtility = AWSS3TransferUtility.defaultS3TransferUtility()
        transferUtility?.getUploadTasks().continueWithBlock({
            (task) in
            print("getUploadTasks ContinueBlock")
            if let uploadTasks = task.result as? [AWSS3TransferUtilityUploadTask] {

            }
            return nil
        })
Was this page helpful?
0 / 5 - 0 ratings

Related issues

thomers picture thomers  路  3Comments

ChrisInspect picture ChrisInspect  路  4Comments

minhthuc251 picture minhthuc251  路  4Comments

dougboberg picture dougboberg  路  5Comments

premiumbosslimited picture premiumbosslimited  路  3Comments