IOS Swift Amazon S3传输实用程序nil与预期的参数类型nsurl不兼容

时间:2016-04-01 13:59:36

标签: ios swift amazon-s3

enter image description here

我是Amazon S3的新手,正在尝试在GitHub https://github.com/awslabs/aws-sdk-ios-samples/tree/master/S3BackgroundTransfer-Sample/Swift中找到的示例 但是当我尝试构建并运行时,我收到以下错误消息

nil与预期的参数类型nsurl

不兼容

下面是我遇到问题的代码。

let transferUtility = AWSS3TransferUtility.defaultS3TransferUtility()

    transferUtility.downloadToURL(nil, bucket: S3BucketName, key: S3DownloadKeyName, expression: expression, completionHander: completionHandler).continueWithBlock { (task) -> AnyObject! in
        if let error = task.error {
            NSLog("Error: %@",error.localizedDescription);
            self.statusLabel.text = "Failed"
        }
        if let exception = task.exception {
            NSLog("Exception: %@",exception.description);
            self.statusLabel.text = "Failed"
        }
        if let _ = task.result {
            self.statusLabel.text = "Starting Download"
            NSLog("Download Starting!")
            // Do something with uploadTask.
        }
        return nil;
    }

请让我如何解决这个问题 谢谢

1 个答案:

答案 0 :(得分:2)

不是说我已经使用了AWSS3TransferUtility,但看起来你需要传递一个指向你想要下载文件的NSURL实例。有一个how to do this (in obj-c) on the AWS developer blog的例子。