Aws-sdk-ios: How to supply a AWSS3TransferUtilityProgressBlock in Swift

Created on 5 May 2016  路  2Comments  路  Source: aws-amplify/aws-sdk-ios

The docs seem to be missing the definition of the AWSS3TransferUtilityProgressBlock, and the iOS Objcetive-c guide examples contain what seems to be old API, ie. expression.uploadProgress does not exist any more, but expression.progressBlock exists. But, it's not clear how I can construct this in order to track progress.

Most helpful comment

let expression = AWSS3TransferUtilityUploadExpression()
let progressBlock: AWSS3TransferUtilityProgressBlock?

    progressBlock = {(task, progress) in
        dispatch_async(dispatch_get_main_queue(), {
            print("Progress: \(Float(progress.fractionCompleted))")
        })
    }
    expression.progressBlock = progressBlock

All 2 comments

Actually, wasn't that hard

            let expression = AWSS3TransferUtilityUploadExpression()
            expression.progressBlock = { (task: AWSS3TransferUtilityTask, progress: NSProgress) in
                print(progress.fractionCompleted)
            }

let expression = AWSS3TransferUtilityUploadExpression()
let progressBlock: AWSS3TransferUtilityProgressBlock?

    progressBlock = {(task, progress) in
        dispatch_async(dispatch_get_main_queue(), {
            print("Progress: \(Float(progress.fractionCompleted))")
        })
    }
    expression.progressBlock = progressBlock
Was this page helpful?
0 / 5 - 0 ratings